/* 平台外壳：统一头部、能力面板、授权弹窗、首页 */
.pk-icon { flex: none; display: block; }

/* ---------- 头部 ---------- */
.pk-header {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 12px; flex: none;
  background: var(--pk-surface); border-bottom: 1px solid var(--pk-border);
}
.pk-brand { display: flex; align-items: center; gap: 8px; color: var(--pk-text); font-weight: 650; font-size: 14px; white-space: nowrap; text-decoration: none; }
.pk-brand:hover { text-decoration: none; }
.pk-brand img { border-radius: 7px; }
.pk-sep { width: 1px; height: 22px; background: var(--pk-border); flex: none; }
.pk-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pk-title h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-meta { font-size: 12px; color: var(--pk-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-grow { flex: 1; }

.pk-caps {
  display: flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 6px 0 4px;
  background: transparent; border: 1px solid transparent; border-radius: 999px; color: var(--pk-text-muted); font-weight: 500;
}
.pk-caps:hover, .pk-caps[aria-expanded="true"] { background: var(--pk-surface-2); border-color: var(--pk-border); }
.pk-cap {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; line-height: 18px; white-space: nowrap;
  background: var(--pk-accent-soft); color: var(--pk-accent);
}
.pk-cap[data-cap="memory"] { background: var(--pk-warning-soft); color: var(--pk-warning); }
.pk-cap-safe { background: var(--pk-success-soft); color: var(--pk-success); }

.pk-actions { display: flex; align-items: center; gap: 2px; }
.pk-hbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 8px;
  background: transparent; border: 0; color: var(--pk-text-muted); cursor: pointer; list-style: none;
}
.pk-hbtn::-webkit-details-marker { display: none; }
.pk-hbtn:hover { background: var(--pk-surface-2); color: var(--pk-text); text-decoration: none; }
.pk-hbtn-text { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--pk-accent); }
#pk-theme [data-when] { display: none; }
html:not([data-theme]) #pk-theme [data-when="system"],
html[data-theme="light"] #pk-theme [data-when="light"],
html[data-theme="dark"] #pk-theme [data-when="dark"] { display: block; }

.pk-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
  background: var(--pk-accent-soft); color: var(--pk-accent); font-size: 12px; font-weight: 700;
}
.pk-user { position: relative; }
.pk-user > summary { list-style: none; }
.pk-menu {
  position: absolute; right: 0; top: 40px; min-width: 220px; padding: 6px;
  background: var(--pk-surface); border: 1px solid var(--pk-border); border-radius: 12px; box-shadow: var(--pk-shadow-lg);
}
.pk-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; border-bottom: 1px solid var(--pk-border); margin-bottom: 4px; }
.pk-menu-head div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pk-menu-head span { font-size: 12px; color: var(--pk-text-muted); overflow: hidden; text-overflow: ellipsis; }
.pk-menu a, .pk-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 0 8px;
  border: 0; border-radius: 8px; background: none; color: var(--pk-text); font-size: 13px; font-weight: 500; justify-content: flex-start;
}
.pk-menu a:hover, .pk-menu button:hover { background: var(--pk-surface-2); text-decoration: none; }
.pk-menu form { margin: 0; }

/* ---------- 能力面板 ---------- */
.pk-panel { position: absolute; z-index: 30; top: 56px; right: 12px; width: min(420px, calc(100vw - 24px)); }
.pk-panel-inner { background: var(--pk-surface); border: 1px solid var(--pk-border); border-radius: 14px; box-shadow: var(--pk-shadow-lg); padding: 14px; }
.pk-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pk-panel-head span, .pk-panel-foot, .pk-panel-desc { font-size: 12px; color: var(--pk-text-muted); }
.pk-panel-desc { margin: 10px 0 0; font-size: 13px; color: var(--pk-text); }
.pk-panel-foot { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--pk-border); }
.pk-cap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pk-cap-row { display: flex; gap: 10px; padding: 8px; border-radius: 10px; }
.pk-cap-row:hover { background: var(--pk-surface-2); }
.pk-cap-row strong { font-size: 13px; }
.pk-cap-row p { margin: 2px 0 0; font-size: 13px; color: var(--pk-text-muted); line-height: 1.5; }
.pk-cap-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: var(--pk-surface-2); color: var(--pk-text-muted); flex: none; }
.pk-consent-state { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--pk-text-muted); }
.pk-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pk-text-subtle); }
.pk-dot.on { background: var(--pk-success); }
.pk-link-btn { min-height: 0; padding: 0; border: 0; background: none; color: var(--pk-danger); font-size: 12px; font-weight: 600; }
.pk-link-btn:hover { background: none; text-decoration: underline; }

/* ---------- 页面舞台 ---------- */
body.pk-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.pk-stage { flex: 1; min-height: 0; display: flex; }
#pk-frame { flex: 1; width: 100%; height: 100%; border: 0; background: var(--pk-bg); display: block; }

/* ---------- 授权弹窗 ---------- */
.pk-dialog {
  width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--pk-border); border-radius: 16px;
  background: var(--pk-surface); color: var(--pk-text); box-shadow: var(--pk-shadow-lg);
}
.pk-dialog::backdrop { background: rgb(10 10 20 / 0.45); backdrop-filter: blur(2px); }
.pk-dialog h2 { font-size: 17px; margin: 12px 0 8px; }
.pk-dialog p { font-size: 14px; color: var(--pk-text-muted); }
.pk-dialog-icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; background: var(--pk-warning-soft); color: var(--pk-warning); }
.pk-dialog-note { font-size: 12px !important; }
.pk-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- toast ---------- */
.pk-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--pk-text); color: var(--pk-bg); font-size: 13px; font-weight: 500; box-shadow: var(--pk-shadow-lg);
  transition: opacity 0.2s, transform 0.2s;
}
.pk-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 站点页（首页 / 登录） ---------- */
body.pk-site { min-height: 100vh; }
.pk-auth { display: flex; justify-content: center; padding: 64px 16px; }
.pk-auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 10px; }
.pk-auth-card h1 { font-size: 22px; margin: 6px 0 0; }
.pk-auth-card img { border-radius: 10px; }
.pk-auth-card .pk-btn { margin-top: 6px; min-height: 40px; }
.pk-error { color: var(--pk-danger); background: var(--pk-danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin: 0; }

.pk-hero { padding: 40px 0 28px; max-width: 680px; }
.pk-hero h1 { font-size: clamp(26px, 5vw, 36px); }
.pk-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.pk-prompt h2 { font-size: 16px; margin-bottom: 6px; }
.pk-copyline { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 10px 10px 14px; background: var(--pk-surface-2); border-radius: 10px; }
.pk-copyline code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 13px; overflow-wrap: anywhere; }

.pk-section { margin-top: 28px; }
.pk-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.pk-section-head h2 { font-size: 16px; margin: 0; }
.pk-grid2 { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); align-items: start; }
.pk-mt { margin-top: 16px; }
.pk-list { list-style: none; margin: 0; padding: 4px; }
.pk-list > li + li { border-top: 1px solid var(--pk-border); }
.pk-row-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px; color: var(--pk-text); border-radius: 10px; }
.pk-row-link:hover { background: var(--pk-surface-2); text-decoration: none; }
.pk-row-link > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.pk-row-link .pk-muted { font-size: 13px; }
.pk-row-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.pk-mem { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 12px; font-size: 14px; }
.pk-mem > div { min-width: 0; overflow-wrap: anywhere; }
.pk-mem form { margin: 0; flex: none; }
.pk-mem .pk-small { display: block; margin-top: 2px; font-size: 12px; }
.pk-tag { display: inline-block; padding: 0 6px; margin-right: 4px; border-radius: 5px; background: var(--pk-surface-2); color: var(--pk-text-muted); font-size: 12px; font-family: var(--pk-font-mono); }
.pk-icon-btn { min-height: 0; width: 30px; height: 30px; padding: 0; border: 0; background: none; color: var(--pk-text-subtle); border-radius: 8px; }
.pk-icon-btn:hover { color: var(--pk-danger); background: var(--pk-danger-soft); }

@media (max-width: 640px) {
  .pk-brand span, .pk-sep, .pk-hide-sm, .pk-caps .pk-cap span { display: none; }
  .pk-cap { padding: 3px 5px; }
  .pk-header { gap: 8px; padding: 0 8px; }
  .pk-caps { padding: 0 4px; }
  .pk-caps > .pk-icon { display: none; }
}
