/* 首页（hub）、登录页、弹窗与设置面板 —— 复用 styles.css 的主题令牌 */

/* ── 通用弹窗 ─────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(8, 12, 18, 0.5); padding: 20px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(560px, 100%); max-height: 86vh; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { margin: 0; font-size: 14.5px; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line-soft);
}
.modal-foot .error { margin-right: auto; color: var(--danger); font-size: 12px; }
.icon-btn {
  background: transparent; border: none; cursor: pointer; color: var(--text-mute);
  font-size: 16px; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: var(--bg-elev); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--text-dim); }
.field .tip { font-size: 11px; color: var(--text-mute); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); }

/* ── 登录页 ───────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: min(380px, 100%); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 30px 26px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-brand .mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 16px;
}
.login-card h1 { margin: 0; font-size: 17px; }
.login-card p.sub { margin: 4px 0 22px; font-size: 12px; color: var(--text-mute); }
.login-card .field { margin-bottom: 12px; }
.login-card .btn.primary { width: 100%; padding: 9px; margin-top: 4px; }
.login-error { min-height: 18px; font-size: 12px; color: var(--danger); margin-top: 8px; }

/* ── 首页 ─────────────────────────────────────────────────────────────── */
.hub-shell { min-height: 100vh; }
.hub-header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 32px; border-bottom: 1px solid var(--line-soft);
  background: var(--bg-side); position: sticky; top: 0; z-index: 20;
}
.hub-brand { display: flex; align-items: center; gap: 10px; }
.hub-brand .mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 15px;
}
.hub-brand h1 { margin: 0; font-size: 15px; letter-spacing: 0.2px; }
.hub-brand .sub { font-size: 10.5px; color: var(--text-mute); }
.hub-search { flex: 1; min-width: 240px; max-width: 560px; position: relative; }
.hub-search input {
  width: 100%; font: inherit; font-size: 13.5px;
  padding: 9px 14px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text); outline: none;
}
.hub-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hub-actions { display: flex; gap: 8px; align-items: center; }
.hub-user { font-size: 11.5px; color: var(--text-mute); }

.hub-main { max-width: 1120px; margin: 0 auto; padding: 26px 32px 80px; }
.hub-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 0 12px;
}
.hub-section-head h2 { margin: 0; font-size: 14px; letter-spacing: 0.3px; }
.hub-section-head .count { font-size: 11.5px; color: var(--text-mute); }

.space-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.space-card {
  display: block; padding: 16px 18px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--line);
  transition: 0.16s ease; position: relative;
}
.space-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.space-card h3 { margin: 0 0 4px; font-size: 14.5px; color: var(--text); }
.space-card .desc { font-size: 12px; color: var(--text-dim); min-height: 34px; line-height: 1.5; }
.space-card .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-mute); margin-top: 10px; }
.space-card .manage {
  position: absolute; top: 10px; right: 10px; opacity: 0;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-dim); cursor: pointer;
}
.space-card:hover .manage { opacity: 1; }
.space-card.create {
  border-style: dashed; display: grid; place-items: center;
  color: var(--text-mute); font-size: 13px; min-height: 128px; background: transparent;
}
.space-card.create:hover { color: var(--accent); }

.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 7px 4px; font-size: 12.5px; border-bottom: 1px solid var(--line-soft);
}
.recent-row:last-child { border-bottom: none; }
.recent-row .when { font-family: var(--mono); font-size: 11px; color: var(--text-mute); min-width: 110px; }
.recent-row .space-tag {
  font-size: 10.5px; color: var(--accent); background: var(--accent-soft);
  border-radius: 20px; padding: 1px 8px; white-space: nowrap;
}
.recent-row .page { color: var(--text); }
.recent-row .note { color: var(--text-mute); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 搜索结果 */
.search-panel { display: none; }
.search-panel.active { display: block; }
.search-group { margin-bottom: 18px; }
.search-group-head {
  font-size: 12px; color: var(--text-dim); margin-bottom: 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.search-group-head .count { font-size: 11px; color: var(--text-mute); }
.search-hit {
  display: block; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--line-soft); margin-bottom: 6px; background: var(--bg-card);
}
.search-hit:hover { border-color: var(--accent); text-decoration: none; }
.search-hit .hit-title { font-size: 13px; color: var(--text); }
.search-hit .hit-line { font-size: 11.5px; color: var(--text-mute); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 空间内：抓取设置 ─────────────────────────────────────────────────── */
.ingest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .ingest-grid { grid-template-columns: 1fr; } }
.ingest-note { font-size: 11.5px; color: var(--text-mute); line-height: 1.6; }
.source-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.source-pill {
  font-size: 12px; padding: 5px 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text-dim);
}
.source-pill[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── 移动端 ─────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  /* 首页头部 */
  .hub-header {
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    gap: 10px;
    align-items: center;
  }
  .hub-brand { flex: 1; min-width: 0; }
  .hub-brand h1 { font-size: 15px; }
  .hub-brand .sub { display: none; }
  .hub-search { order: 3; flex-basis: 100%; max-width: none; min-width: 0; }
  .hub-search input { padding: 10px 13px; font-size: 14px; }
  .hub-actions { gap: 6px; flex: none; }
  .hub-actions .btn { padding: 7px 11px; font-size: 12px; }
  .hub-user { display: none; }

  .hub-main { padding: 16px 14px calc(60px + env(safe-area-inset-bottom)); }
  .hub-section-head { margin: 20px 0 10px; }
  .space-grid { grid-template-columns: 1fr; gap: 10px; }
  .space-card { padding: 14px 15px; }
  .space-card .desc { min-height: 0; }
  .space-card.create { min-height: 88px; }
  .space-card .manage { opacity: 1; }  /* 手机没有 hover，管理按钮常驻 */

  .recent-row { flex-wrap: wrap; gap: 4px 10px; padding: 9px 2px; }
  .recent-row .when { min-width: 0; font-size: 10.5px; }
  .recent-row .page { flex: 1 1 100%; order: 3; font-size: 13px; }
  .recent-row .note { display: none; }

  .search-group-head { font-size: 13px; }
  .search-hit { padding: 11px 13px; }
  .search-hit .hit-title { font-size: 13.5px; }
  .search-hit .hit-line { font-size: 12px; }

  /* 弹窗：手机上占满宽度、贴底 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    width: 100%; max-height: 90dvh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head { padding: 16px 18px; }
  .modal-body { padding: 14px 18px; gap: 14px; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .field-row, .ingest-grid { grid-template-columns: 1fr; }
  input[type="text"], input[type="number"], input[type="search"],
  input[type="password"], select, textarea { font-size: 16px; }  /* 防 iOS 聚焦缩放 */

  /* 登录页 */
  .login-shell { padding: 18px; align-items: center; }
  .login-card { padding: 24px 20px; border-radius: 14px; }
  .login-card h1 { font-size: 16px; }
  .login-card input { font-size: 16px; padding: 10px 12px; }
  .login-card .btn.primary { padding: 11px; font-size: 13.5px; }
}

@media (max-width: 420px) {
  .hub-header { padding-left: 12px; padding-right: 12px; }
  .hub-actions .btn { padding: 7px 9px; font-size: 11.5px; }
  .hub-main { padding-left: 12px; padding-right: 12px; }
}