/* ============ 门户主页(站点自有风格) ============ */
.home-body {
  --accent: #c96442;
  --fg: #2c2a24;
  --fg-dim: #8a8678;
  --border: #e8e5da;
  --bg-main: #faf9f5;
  --bg-panel: #ffffff;
  --error: #b02d2d;
  --state-bg: #ffffff;
  --state-bg-hover: #f5f1e8;
  background: var(--bg-main); color: var(--fg); overflow: hidden;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ---- 认证表单 ---- */
.auth-tabs { display: flex; gap: 4px; margin: 18px 0; padding: 4px; border: 1px solid var(--border, #ddd); border-radius: 999px; background: var(--bg-soft, #f5f3ed); }
.login-card .auth-tab { width: auto; flex: 1; padding: 8px 3px; border: 0; border-radius: 999px; background: transparent; color: var(--fg-dim, #888); font-size: 12px; }
.login-card .auth-tab.active { background: var(--bg-panel, #fff); color: var(--fg, #2c2a24); box-shadow: 0 1px 4px rgba(0,0,0,.08); font-weight: 600; }
.auth-extra.hidden { display: none !important; }
.captcha-box { margin: 0 0 12px; padding: 10px; border: 1px solid var(--border, #ddd); border-radius: 10px; background: var(--bg-soft, #f5f3ed); text-align: left; }
.captcha-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--fg-dim, #888); font-size: 12px; }
.captcha-head button { border: 0; background: none; color: var(--accent, #d97757); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.captcha-row { display: flex; align-items: center; gap: 8px; }
.captcha-row img { display: block; width: 150px; height: 48px; flex: 0 0 150px; border: 1px solid var(--border, #ddd); border-radius: 7px; background: #fff; }
.captcha-row input { min-width: 0; margin: 0; }
.auth-notice { margin: -4px 0 12px; color: var(--fg-dim, #888); font-size: 12px; line-height: 1.6; text-align: left; }

.portal {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---- 左侧菜单 ---- */
.portal-nav {
  width: 232px; flex-shrink: 0; display: flex; flex-direction: column;
  background: #f2f0e9; border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
}
.portal-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15.5px; font-weight: 700; padding: 0 8px 18px;
}
.portal-brand-icon { color: var(--accent); display: flex; }

.portal-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: #fff;
  border: 1px solid var(--border); margin-bottom: 14px;
}
.portal-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.portal-user-name { font-size: 13.5px; font-weight: 600; }
.portal-user-balance { font-size: 11.5px; color: var(--fg-dim); margin-top: 2px; }
.portal-user-balance b { color: var(--accent); }

.portal-menu { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pnav {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: none; background: none; text-align: left;
  border-radius: 9px; font-size: 13.5px; color: #55523f;
  text-decoration: none; cursor: pointer;
}
.pnav svg { color: #9b9782; flex-shrink: 0; }
.pnav:hover { background: rgba(44, 42, 36, .06); }
.pnav.active { background: var(--accent); color: #fff; font-weight: 500; }
.pnav.active svg { color: #fff; }
.portal-nav-bottom { border-top: 1px solid var(--border); padding-top: 8px; }

/* ---- 右侧内容 ---- */
.portal-main { flex: 1; overflow-y: auto; padding: 34px 42px; min-width: 0; }
.psec-head { margin-bottom: 22px; }
.psec-head h1 { font-size: 22px; font-weight: 700; }
.psub { margin-top: 6px; font-size: 13px; color: var(--fg-dim); }

/* 模型广场 */
.provider-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px; max-width: 1080px;
}
.provider-card {
  position: relative; text-align: left; cursor: pointer;
  background: #fff; color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 24px 24px 20px;
  transition: transform .15s ease, box-shadow .15s ease;
  overflow: hidden;
}
.provider-card:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(0, 0, 0, .1); }
.pc-mark {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.pc-mark img { width: 44px; height: 44px; border-radius: 11px; display: block; }
.pc-mark svg { width: 24px; height: 24px; }
.pc-name { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.pc-desc { margin-top: 5px; font-size: 12.5px; color: var(--fg-dim); line-height: 1.6; }
.pc-models { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.pc-chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #f2f2f2; color: #555;
}
.pc-enter {
  margin-top: 16px; font-size: 13px; font-weight: 600;
  color: #111;
  display: flex; align-items: center; gap: 6px;
}
.provider-card:hover .pc-enter { gap: 10px; }
.pc-enter svg { transition: transform .15s; }

/* 通用卡片 */
.pcard {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; max-width: 860px;
}
.pcard h3 { font-size: 14.5px; margin-bottom: 12px; }
.subscription-list { display: grid; gap: 14px; max-width: 860px; }
.subscription-card.is-expired { opacity: .7; }
.subscription-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.subscription-card-head h3 { margin-bottom: 6px; }
.subscription-status { display: inline-flex; padding: 3px 8px; border-radius: 999px; background: rgba(27, 118, 71, .1); color: #1b7647; font-size: 12px; }
.is-expired .subscription-status { background: rgba(120, 114, 102, .12); color: var(--fg-dim); }
.subscription-expiry { color: var(--fg-dim); font-size: 12px; white-space: nowrap; }
.subscription-quota-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.subscription-quota-grid > div { padding: 12px; border-radius: 10px; background: var(--bg-soft); display: flex; flex-direction: column; gap: 3px; }
.subscription-quota-grid b { font-size: 24px; color: var(--accent); }
.subscription-quota-grid span { font-size: 12px; }
.subscription-quota-grid small { color: var(--fg-dim); font-size: 11px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.profile-grid > div { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.plabel { font-size: 11.5px; color: var(--fg-dim); }
.accent { color: var(--accent); }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .field-with-label { display: flex; flex: 1 1 150px; flex-direction: column; gap: 6px; min-width: 0; color: var(--fg-dim); font-size: 12px; font-weight: 600; }
.form-row .field-with-label input { width: 100%; }
.form-row .field-with-label select { width: 100%; }
.agent-package-info { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg-dim); font-size: 12px; line-height: 1.6; }
.form-row input {
  flex: 1; min-width: 200px; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: inherit; outline: none; font-size: 13.5px;
}
.form-row input:focus { border-color: var(--accent); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .5px; }
.agent-card-result-wrap { display: flex; align-items: stretch; gap: 10px; margin-top: 12px; }
.agent-card-result-wrap textarea { flex: 1; min-width: 0; }
.agent-card-copy { align-self: flex-start; white-space: nowrap; }
@media (max-width: 680px) {
  .agent-card-result-wrap { flex-direction: column; }
  .agent-card-copy { align-self: stretch; }
}
.form-status { min-height: 20px; margin-top: 8px; font-size: 13px; }
.access-expired {
  margin-top: 14px; padding: 11px 14px; border: 1px solid rgba(176, 45, 45, .35);
  border-radius: 12px; background: rgba(176, 45, 45, .07); color: #9d3434;
  font-size: 13px; line-height: 1.5;
}
.provider-card.is-access-locked { opacity: .62; cursor: not-allowed; }
.provider-card.is-access-locked .pc-enter { color: var(--fg-dim); }
.primary-btn.ghost { background: none; border: 1px solid var(--accent); color: var(--accent); }
.portal-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  max-width: min(420px, calc(100vw - 32px)); padding: 10px 18px;
  border-radius: 999px; transform: translateX(-50%);
  background: rgba(31, 30, 29, .94); color: #fff; font-size: 13px;
  line-height: 1.5; text-align: center; overflow-wrap: anywhere; pointer-events: none;
}
.portal-toast.success { background: rgba(27, 118, 71, .95); }
.portal-toast.error { background: rgba(176, 45, 45, .96); }

@media (max-width: 760px) {
  .portal-nav { width: 64px; padding: 14px 8px; }
  .portal-brand span:last-child, .portal-user-info, .pnav { font-size: 0; }
  .pnav { justify-content: center; padding: 10px 0; }
  .pnav svg { width: 18px; height: 18px; }
  .portal-user { justify-content: center; padding: 6px; }
  .portal-main { padding: 20px 16px; }
  .provider-grid { grid-template-columns: minmax(0, 1fr); }
  .provider-card { min-width: 0; padding-inline: 20px; }
  .subscription-card-head { flex-direction: column; }
  .subscription-quota-grid { gap: 6px; }
}

/* 厂商卡片背景已统一为白色；图标本身携带品牌色背景 */

/* 记录列表加载、空状态与区域重试 */
.record-state {
  min-height: 58px;
  color: var(--fg-dim);
}
.record-state.error { color: var(--error); }
.record-state:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}
.record-focus-target:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}
.retry-btn {
  border-color: currentColor;
  background: var(--state-bg);
}
.retry-btn:hover:not(:disabled) { background: var(--state-bg-hover); }
.retry-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (hover: none), (pointer: coarse) {
  .retry-btn { min-width: 44px; min-height: 44px; }
}

:where(a, button, input, select, textarea, .provider-card, .record-state, .record-focus-target):focus-visible {
  outline: 2px solid #fff !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px #0b3d91 !important;
}
:where(.form-row input, .record-state, .record-focus-target, .retry-btn):focus-visible {
  outline: 2px solid #fff !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px #0b3d91 !important;
}
/* 输入框聚焦时不使用全局双线焦点环,由 .form-row input:focus 提供 border 聚焦样式 */
:where(input, select, textarea):focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

@media (forced-colors: active) {
  body, .portal, .portal-nav, .portal-main, .provider-card, .pcard, .record-state { background: Canvas; color: CanvasText; border-color: CanvasText; }
  :where(.form-row input, button, .primary-btn, .retry-btn) { background: ButtonFace; color: ButtonText; border-color: ButtonText; }
  :where(.pnav.active, .pnav[aria-current="page"]) { background: Highlight; color: HighlightText; border: 2px solid HighlightText; }
  :where(.pc-desc, .plabel, .record-state:not(.error)) { color: CanvasText; }
  input::placeholder { color: GrayText; }
  :where(a, button, input, select, textarea, .provider-card, .record-state, .record-focus-target,
  .form-row input, .retry-btn):focus-visible { outline: 2px solid Highlight !important; outline-offset: 2px; box-shadow: none !important; }
  :where(input, select, textarea):focus-visible { outline: none !important; box-shadow: none !important; border-color: Highlight !important; }
  .portal-toast { background: Canvas; color: CanvasText; border: 2px solid CanvasText; }
  .portal-toast.success { border-color: Highlight; }
  .portal-toast.error, .record-state.error { color: CanvasText; border: 2px solid CanvasText; }
  .form-status.err {
    color: CanvasText;
    border-inline-start: 3px solid CanvasText;
    padding-inline-start: 8px;
  }
  .access-expired { color: CanvasText; border-color: CanvasText; background: Canvas; }
  .form-status.ok {
    color: CanvasText;
    border-inline-start: 3px solid Highlight;
    padding-inline-start: 8px;
  }
  .retry-btn:disabled { color: GrayText; border-color: GrayText; }
}

@media (prefers-contrast: more) {
  .home-body { --fg-dim: color-mix(in srgb, var(--fg) 82%, transparent); --border: color-mix(in srgb, var(--fg) 62%, transparent); }
  :where(.pc-desc, .plabel, .record-state) { color: var(--fg); }
  :where(.provider-card, .pcard, .form-row input, .retry-btn) { border-color: currentColor; }
  :where(.pnav.active, .pnav[aria-current="page"]) { border: 2px solid currentColor; font-weight: 700; }
  :where(a, button, input, select, textarea, .provider-card, .record-state, .record-focus-target,
  .form-row input, .retry-btn):focus-visible { outline: 2px solid #fff !important; outline-offset: 2px; box-shadow: 0 0 0 6px #0b3d91 !important; }
  :where(input, select, textarea):focus-visible { outline: none !important; box-shadow: none !important; border-color: Highlight !important; }
}
