:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e4e7eb;
  --border-strong: #d0d5da;
  --text: #1f2328;
  --text-2: #656d76;
  --text-3: #8b949e;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-weak: #eef2ff;
  --danger: #d1242f;
  --danger-weak: #fff0f0;
  --ok: #1a7f37;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(27, 31, 36, 0.06), 0 4px 12px rgba(27, 31, 36, 0.05);
}

* {
  box-sizing: border-box;
}

/* 必须放在组件规则之前生效：下面很多元素设了 display，
   会覆盖 hidden 属性自带的 display:none，这里统一兜住 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

input,
textarea {
  font-family: inherit;
  font-size: 14px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--text-3);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-weak);
  border-color: var(--danger);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

/* ---------- 输入 ---------- */

.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.topbar-brand .logo {
  width: 22px;
  height: 22px;
  flex: none;
}

.topbar-spacer {
  flex: 1;
}

/* ---------- 容器 ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.page-sub {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 13px;
}

/* ---------- 卡片列表 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  color: var(--text-3);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.card-actions .btn {
  flex: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
}

.tag-share {
  background: var(--accent-weak);
  color: var(--accent);
}

.tag-off {
  background: var(--surface-2);
  color: var(--text-3);
}

.empty {
  text-align: center;
  padding: 72px 20px;
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* ---------- 弹层 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 31, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(27, 31, 36, 0.2);
  padding: 22px;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.modal p {
  margin: 0 0 16px;
  color: var(--text-2);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.radio-item:hover {
  border-color: var(--border-strong);
}

.radio-item.active {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.radio-item input {
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.radio-item strong {
  display: block;
  font-weight: 500;
  font-size: 13.5px;
}

.radio-item span {
  color: var(--text-2);
  font-size: 12.5px;
}

.share-link-box {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.share-link-box .input {
  font-size: 13px;
  color: var(--text-2);
}

/* ---------- 提示 ---------- */

#toast-host {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #24292f;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(27, 31, 36, 0.25);
  animation: toast-in 0.18s ease-out;
  max-width: 80vw;
}

.toast.err {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
