/* ==========================================================================
   StudyOps — components.css
   12 栏栅格、卡片、徽章、按钮、弹窗、响应式（自原 styles.css 拆出）
   ========================================================================== */
/* ---------- 12-col grid ---------- */
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.stack-8 { display: flex; flex-direction: column; gap: 32px; }
.stack-6 { display: flex; flex-direction: column; gap: 24px; }
.stack-4 { display: flex; flex-direction: column; gap: 16px; }
.stack-3 { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Cards ---------- */
.card {
  padding: 24px;
  border-radius: 2px;
  border: 1px solid var(--card-border);
  background-color: var(--card-bg);
  transition: background-color 0.3s ease, border-color 0.15s ease;
}
.card-sm { padding: 20px; }
.card-hoverable { cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); }
.card-hoverable:hover { background-color: var(--hover); }
.card-hoverable:hover.accent-blue { border-color: var(--accent); }
.card-hoverable:hover.accent-red { border-color: var(--red-500); }
.card-hoverable:hover.accent-amber { border-color: var(--amber-500); }
.card-hoverable:hover.accent-emerald { border-color: var(--emerald-500); }

.panel {
  padding: 16px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background-color: var(--soft-panel);
}

.panel-label { font-size: 11px; margin-bottom: 4px; color: var(--sub); }
.panel-num { font-size: 24px; font-weight: 700; }
.panel-num .num-sub { font-size: 12px; font-weight: 400; opacity: 0.6; }
.panel-foot { font-size: 10px; margin-top: 4px; color: var(--sub); }

.card-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--accent); }

.card-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.view-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.view-eyebrow { font-size: 12px; letter-spacing: 0.15em; color: var(--sub); }

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.view-head-btns { display: flex; align-items: center; gap: 8px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

/* Progress bars */
.progress-track {
  width: 100%;
  background-color: var(--gray-20);
  border-radius: 2px;
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-track-lg { height: 6px; margin-top: 0; background-color: var(--gray-10); }
.progress-fill {
  background-color: var(--accent);
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.fill-blue { background-color: var(--blue-500); }
.fill-red { background-color: var(--red-500); }
.fill-amber { background-color: var(--amber-500); }
.fill-emerald { background-color: var(--emerald-500); }

/* Badges & chips */
.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid;
  white-space: nowrap;
}
.badge-blue { background-color: rgba(59, 130, 246, 0.1); color: var(--blue-500); border-color: rgba(59, 130, 246, 0.2); }
.badge-red { background-color: rgba(239, 68, 68, 0.1); color: var(--red-500); border-color: rgba(239, 68, 68, 0.2); }
.badge-emerald { background-color: rgba(16, 185, 129, 0.1); color: var(--emerald-600); border-color: rgba(16, 185, 129, 0.2); }
.badge-accent { background-color: rgba(91, 159, 211, 0.1); color: var(--accent); border-color: rgba(91, 159, 211, 0.2); }
.badge-ontrack {
  color: var(--emerald-600); font-weight: 600;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 2px 8px; border-radius: 2px; font-size: 11px;
}

.tag-chip {
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 9px;
  background-color: var(--gray-10);
  border: 1px solid var(--gray-20);
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Buttons used inside views */
.btn-tab {
  padding: 6px 12px;
  border-radius: 2px;
  font-size: 12px;
  border: 1px solid var(--border);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn-tab.active-blue { background-color: var(--accent); color: #fff; border-color: var(--accent); }
.btn-tab.active-amber { background-color: var(--amber-500); color: #fff; border-color: var(--amber-500); }
.btn-tab.active-emerald { background-color: var(--emerald-600); color: #fff; border-color: var(--emerald-600); }
.btn-tab.active-red { background-color: var(--red-500); color: #fff; border-color: var(--red-500); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.btn-pill {
  padding: 6px 14px;
  border-radius: 2px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--sub);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn-pill:hover { background-color: var(--hover); }
.btn-pill.active { background-color: var(--accent); color: #fff; font-weight: 700; border-color: var(--accent); }

.btn-mini {
  padding: 4px 10px;
  border-radius: 2px;
  font-size: 10px;
  border: 1px solid var(--border);
  color: var(--sub);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn-mini.active { background-color: var(--accent); color: #fff; font-weight: 700; border-color: var(--accent); }

.btn-add-entry {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid rgba(91, 159, 211, 0.3);
  color: var(--accent);
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-add-entry:hover { background-color: rgba(91, 159, 211, 0.1); }

.btn-copy {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-copy:hover { background-color: var(--hover); }

/* Subject card arrow */
.card-arrow {
  opacity: 0.4;
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.card-hoverable:hover .card-arrow { opacity: 1; transform: translate(2px, -2px); }
.card-hoverable:hover .card-arrow.arrow-blue { color: var(--accent); }
.card-hoverable:hover .card-arrow.arrow-red { color: var(--red-500); }
.card-hoverable:hover .card-arrow.arrow-amber { color: var(--amber-500); }
.card-hoverable:hover .card-arrow.arrow-emerald { color: var(--emerald-500); }

/* Lists */
.bullet-list { margin: 0; padding-left: 0; list-style: none; font-size: 12px; color: var(--sub); display: flex; flex-direction: column; gap: 4px; }
.disc-list { margin: 0; padding-left: 18px; font-size: 12px; color: var(--sub); display: flex; flex-direction: column; gap: 6px; }
.disc-list li::marker { color: var(--sub); }

/* Tasks & logs */
.scroll-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.task-row {
  padding: 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.task-row:not(.done):hover { background-color: var(--hover); }
.task-row.done { opacity: 0.5; background-color: var(--soft-panel); }
.task-text { flex: 1; user-select: none; }
.task-row.done .task-text { text-decoration: line-through; }

.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background-color: var(--soft-panel);
  font-size: 12px;
}
.log-left { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.log-time { font-size: 10px; color: #9ca3af; flex-shrink: 0; }
.log-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-status { font-size: 10px; color: var(--emerald-600); letter-spacing: 0.08em; flex-shrink: 0; margin-left: 8px; }

/* English view */
.sentence-box { font-size: 12px; line-height: 1.7; display: flex; flex-direction: column; gap: 12px; }
.sentence-label { color: var(--blue-500); font-weight: 600; margin: 0; }
.sentence-text { font-style: italic; font-size: 14px; line-height: 1.5; margin: 0; }
.dashed-top { padding-top: 12px; border-top: 1px dashed var(--border); }
.struct-head { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.struct-list strong { text-transform: uppercase; font-family: ui-monospace, Menlo, monospace; color: var(--text); }
.trans-head { font-size: 12px; font-weight: 700; color: var(--emerald-600); display: block; margin-bottom: 4px; }
.trans-text { font-size: 12px; line-height: 1.7; color: var(--sub); margin: 0; }

.tpl-box { padding: 12px; border-radius: 2px; border: 1px solid var(--border); background-color: var(--soft-panel); font-size: 12px; }
.tpl-name { font-weight: 700; color: var(--accent); font-family: ui-monospace, Menlo, monospace; }
.tpl-text { font-size: 11px; font-style: italic; color: var(--sub); margin: 4px 0 0; }

/* Politics */
.tl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tl-year {
  padding: 8px 4px;
  border-radius: 2px;
  font-size: 12px;
  border: 1px solid var(--border);
  text-align: center;
  color: var(--sub);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.tl-year.active { background-color: var(--red-500); color: #fff; border-color: var(--red-500); font-weight: 700; }
.tl-detail { display: flex; flex-direction: column; gap: 8px; }
.tl-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-title { font-size: 16px; font-weight: 700; color: var(--red-500); }
.tl-detail-text { font-size: 12px; line-height: 1.7; color: var(--sub); margin: 0; }

/* Math */
.math-box { font-size: 12px; line-height: 1.7; display: flex; flex-direction: column; gap: 12px; }
.math-goal { color: var(--amber-500); font-weight: 700; }
.math-steps { list-style: decimal; padding-left: 18px; font-size: 12px; color: var(--sub); display: flex; flex-direction: column; gap: 12px; margin: 0; }
.math-steps li, .rolle-conds li {
  padding: 8px;
  border-radius: 2px;
  border: 1px dashed currentColor;
}
.math-steps strong { color: var(--text); }
.rolle-conds { list-style: disc; padding-left: 18px; font-size: 12px; color: var(--sub); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.math-corollary {
  padding: 10px;
  border-radius: 2px;
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  font-size: 11px;
  color: var(--amber-600);
  font-family: ui-monospace, Menlo, monospace;
}

/* OR simplex table */
.table-wrap { overflow-x: auto; }
.simplex-table { width: 100%; text-align: left; font-size: 12px; border-collapse: collapse; }
.simplex-table th, .simplex-table td { padding: 10px; }
.simplex-table thead tr { border-bottom: 1px solid var(--border); background-color: var(--soft-panel); }
.simplex-table tbody tr { border-bottom: 1px solid var(--border); }
.simplex-table tbody tr:last-child { border-bottom: none; }
.simplex-table .cell-r { border-right: 1px solid var(--gray-20); }
.simplex-table tbody { color: var(--sub); }
.simplex-table .t-strong { color: var(--text); }
.row-out { background-color: rgba(245, 158, 11, 0.05); }
.row-sigma { background-color: rgba(16, 185, 129, 0.1); font-weight: 700; color: var(--emerald-600); }
.col-in { background-color: rgba(16, 185, 129, 0.1); color: var(--emerald-600); font-weight: 700; }
.col-pivot { background-color: rgba(16, 185, 129, 0.2); color: var(--emerald-600); font-weight: 700; }
.sigma-max { color: var(--emerald-700); font-weight: 800; }
.th-in { background-color: rgba(16, 185, 129, 0.1); color: var(--emerald-600); }

/* Terms */
.term-search-wrap { position: relative; }
.term-search-wrap .icon-sm {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  opacity: 0.5; pointer-events: none;
}
.term-search {
  padding: 8px 12px 8px 32px;
  border-radius: 2px;
  font-size: 12px;
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  width: 256px;
  outline: none;
  transition: border-color 0.15s ease;
}
.term-search:focus { border-color: var(--accent); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

.term-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s ease, background-color 0.3s ease;
}
.term-card:hover { border-color: var(--accent); }
.term-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.term-id { font-size: 10px; color: var(--sub); }
.term-name { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.term-desc { font-size: 12px; line-height: 1.7; color: var(--sub); margin: 0; }
.term-foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.term-link { font-size: 10px; color: var(--sub); display: flex; align-items: center; gap: 4px; }
.term-link .icon-xs { color: var(--accent); }
.terms-empty { padding: 48px; text-align: center; font-size: 12px; color: var(--sub); font-family: ui-monospace, Menlo, monospace; }

/* Answer card */
.score-grid { margin-bottom: 24px; }
.score-num { font-size: 24px; font-weight: 700; }
.score-deduct { font-size: 12px; color: var(--red-500); font-weight: 400; }
.ded-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.ded-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; }
.ded-filters { display: flex; gap: 6px; }
.ded-list { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.ded-row {
  padding: 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background-color: var(--soft-panel);
}
.ded-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ded-name { font-weight: 700; font-family: ui-monospace, Menlo, monospace; color: var(--accent); }
.ded-type {
  font-size: 9px; font-family: ui-monospace, Menlo, monospace;
  padding: 1px 6px; border-radius: 2px;
  background-color: rgba(239, 68, 68, 0.1); color: var(--red-500);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.ded-desc { color: var(--sub); margin: 2px 0 0; }
.ded-pts { color: var(--red-500); font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  /* 高于移动端汉堡按钮(70)与抽屉(65)：弹窗打开时不能被壳层控件压在下面 */
  z-index: 80;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 448px;
  padding: 24px;
  border-radius: 2px;
  border: 1px solid var(--card-border);
  background-color: var(--card-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.modal-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.modal-close { opacity: 0.6; display: flex; align-items: center; justify-content: center; min-height: 40px; min-width: 40px; }
.modal-close:hover { opacity: 1; }

.modal-form { display: flex; flex-direction: column; gap: 16px; font-size: 12px; }
.modal-label { display: block; margin-bottom: 4px; color: var(--sub); font-size: 12px; }
.modal-input {
  width: 100%;
  padding: 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}
.modal-input:focus { border-color: var(--accent); }
.modal-textarea { resize: vertical; font-family: inherit; }
select.modal-input { font-family: ui-monospace, Menlo, monospace; }
select.modal-input option { background-color: var(--card-bg); color: var(--text); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.btn-modal-cancel {
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  font-size: 12px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-modal-cancel:hover { background-color: var(--hover); }
.btn-modal-submit {
  padding: 6px 16px;
  border-radius: 2px;
  background-color: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-modal-submit:hover { background-color: #2563eb; }

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar,
.scroll-list::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track,
.scroll-list::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb,
.scroll-list::-webkit-scrollbar-thumb {
  background-color: var(--gray-20);
  border-radius: 2px;
}

/* 顶部左侧的 logo 装饰：只在移动端显示，纯展示 */
.mobile-logo { display: none; }

/* ---------- Responsive (< 900px) ---------- */
@media (max-width: 900px) {
  .hero { padding: 24px 20px 16px; }
  .hero-nav { flex-direction: column; gap: 12px; }
  .hero-nav-right { gap: 8px; }

  .shell { flex-direction: column; border-radius: 2px 2px 0 0; }
  /* 底部留足安全区：避免 iOS 工具栏/Home 横条盖住最后的按钮 */
  .main { width: 100%; padding: 60px 16px calc(48px + env(safe-area-inset-bottom, 0px)); order: 1; }

  /* 导航收进汉堡抽屉：默认隐藏，右侧滑出 */
  .mobile-menu {
    display: inline-flex;
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 70;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--shell-border);
    border-radius: 2px;
    background-color: var(--shell-bg);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  }
  .mobile-menu .icon { width: 20px; height: 20px; }
  /* 顶部左侧 logo：不另起一条栏，就跟汉堡按钮同一行高、垂直居中对齐；
     z-index 低于 .drawer-backdrop(60)，抽屉打开时跟着页面一起变暗；
     pointer-events:none——它是装饰，不能挡到下面的内容。 */
  .mobile-logo {
    display: flex;
    position: fixed;
    top: 12px;
    left: 14px;
    z-index: 20;
    height: 42px;
    align-items: center;
    pointer-events: none;
  }
  .logo-mobile { height: 26px; width: auto; }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background-color: rgba(0, 0, 0, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
  .rail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 246px;
    min-width: 0;
    height: auto;
    z-index: 65;
    border-left: 1px solid var(--rail-border);
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
    flex-direction: column;
    padding: 20px 16px;
    gap: 0;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
  }
  .shell.drawer-open .rail { transform: translateX(0); }
  .rail-top {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .rail-head {
    border-bottom: 1px dashed var(--border);
    border-right: none;
    padding: 0 0 12px;
  }
  .rail-nav {
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    margin-top: 12px;
    align-items: stretch;
  }
  .rail-nav-item {
    width: 100%;
    padding: 12px 12px;
    min-height: 44px;
    gap: 6px;
  }
  .rail-nav-dot { display: block; }
  .rail-bottom {
    border-top: 1px dashed var(--border);
    padding-top: 12px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .rail-controls { display: flex; gap: 6px; }
  .ctl-btn { padding: 6px 8px; }
  .ctl-label { display: none; }

  /* 单列堆叠 */
  .grid-12 { grid-template-columns: 1fr; }
  .grid-12 > [class*="col-"] { grid-column: span 1; }

  .term-search { width: 100%; }
  .view-head { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* TODAY 卡内 3 小格纵向堆叠 */
  .stat-grid { grid-template-columns: 1fr !important; }
}


/* ---------- 页面级标题已移除，仅保留必要的切换控件 ---------- */
.view-controls-only {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-controls-end { justify-content: flex-end; }

