:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --border: #e4e4e7;
  --border-subtle: #f0f0f2;
  --text: #27272a;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --accent: #52525b;
  --accent-soft: #f4f4f5;
  --accent-hover: #3f3f46;
  --focus-ring: rgba(82, 82, 91, .18);
  --success: #6b7280;
  --success-bg: #f4f4f5;
  --error: #78716c;
  --error-bg: #fafaf9;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.03);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 0) 16px 0;
  height: calc(52px + env(safe-area-inset-top, 0));
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  height: 18px;
  width: auto;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}
.header-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.header-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.header-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Layout ── */
.page {
  padding: 16px 14px calc(env(safe-area-inset-bottom, 0) + 20px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.card-head.compact { margin-bottom: 10px; }
.card-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.card-toggle .toggle-arrow {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform .2s ease, color .15s;
  flex-shrink: 0;
  margin-top: 6px;
}
.card-toggle .toggle-arrow.open { transform: rotate(180deg); }
.card-toggle:hover .toggle-arrow { color: var(--text-secondary); }
.card-body-collapsed {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.card-body-collapsed.open { max-height: 1200px; }
.step-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 2px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Detail (read-only info) ── */
.detail-section + .detail-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.detail-title {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px 6px;
}
@media (min-width: 360px) {
  .detail-grid { grid-template-columns: repeat(4, 1fr); gap: 5px 8px; }
}
@media (min-width: 480px) {
  .detail-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 600px) {
  .detail-grid { grid-template-columns: repeat(6, 1fr); }
}
.detail-field {
  min-width: 0;
  line-height: 1.3;
}
.detail-field .k {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-field .k::after { content: '：'; }
.detail-field .v {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}
.detail-field .v.em-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.detail-field .v.em-bed {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.detail-field.span-all { grid-column: 1 / -1; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}
.badge-m { background: var(--accent-soft); color: var(--text-secondary); }
.badge-f { background: #f5f5f4; color: var(--text-secondary); }

/* ── Guide steps ── */
.guide-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.guide-step {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.guide-step:last-child { border-bottom: none; padding-bottom: 0; }
.guide-step:first-child { padding-top: 0; }
.guide-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.guide-step-body { flex: 1; min-width: 0; }
.guide-step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.guide-step-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}
.guide-step-desc strong { color: var(--text); font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  user-select: none;
  font-family: inherit;
  line-height: 1.4;
  width: 100%;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--surface-muted);
  color: var(--text);
}
.btn-sm { padding: 9px 14px; font-size: 13px; font-weight: 500; }

.cta-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* ── Bookmarklet ── */
.bm-section { margin-top: 4px; }
.bm-browser-tabs { display: flex; gap: 6px; margin: 12px 0; }
.bm-tab {
  flex: 1;
  padding: 7px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--surface);
  transition: background .15s, border-color .15s, color .15s;
}
.bm-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.bm-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.bm-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.bm-step-num {
  min-width: 20px;
  height: 20px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}
.bm-code-wrap {
  background: #27272a;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 4px;
}
.bm-code {
  font-family: var(--mono);
  font-size: 10px;
  color: #e4e4e7;
  line-height: 1.5;
  word-break: break-all;
  user-select: all;
  max-height: 72px;
  overflow-y: auto;
}
.btn-copy-bm {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: #3f3f46;
  color: #e4e4e7;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-copy-bm.copied { background: var(--accent); color: #fff; }
.bm-note {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
}

.sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 14px 0;
}

/* ── Error state ── */
.error-state {
  text-align: center;
  padding: 48px 16px;
}
.error-state .icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }
.error-state h2 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.error-state p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ── Toast ── */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 999;
  transition: transform .3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #78716c; }
