/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-danger: #dc2626;
  --color-text: #1a1a2e;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-success: #16a34a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 24px 0 16px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

main { flex: 1; }

footer {
  text-align: center;
  padding: 24px 0;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s;
  background: var(--color-surface);
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

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

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-secondary {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-block { width: 100%; }

/* ── File list ───────────────────────────────────────────────── */
.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.file-item:last-child { border-bottom: none; }

.file-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Upload area ─────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.04);
}

.upload-area input[type="file"] { display: none; }

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

/* ── Progress bar ────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
  display: none;
}

.progress.active { display: block; }

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert-error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #eff6ff;
  color: var(--color-primary);
  border: 1px solid #bfdbfe;
}

/* ── QR code ─────────────────────────────────────────────────── */
.qr-display {
  text-align: center;
  padding: 16px;
}

.qr-display img {
  max-width: 200px;
  border-radius: var(--radius-sm);
}

.qr-url {
  margin-top: 12px;
  padding: 10px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
  user-select: all;
}

/* ── Status badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: #dcfce7; color: #16a34a; }
.badge-expired { background: #fef2f2; color: #dc2626; }

/* ── WeChat guide overlay ────────────────────────────────────── */
.wechat-guide {
  display: none;
  background: #fff7ed;
  border: 2px solid #f97316;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.wechat-guide.visible { display: block; }

.wechat-guide-title {
  font-weight: 700;
  font-size: 1rem;
  color: #c2410c;
  margin-bottom: 6px;
}

.wechat-guide-steps {
  font-size: 0.9rem;
  color: #7c2d12;
  line-height: 1.6;
}

.wechat-guide-flash {
  animation: flash-border 0.25s ease-in-out 2;
}

@keyframes flash-border {
  0%, 100% { border-color: #f97316; }
  50%       { border-color: #dc2626; background: #fef2f2; }
}

/* ── Share list ──────────────────────────────────────────────── */
.share-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.share-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.share-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.share-card-details {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.share-card-details span {
  margin-right: 12px;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-secondary);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ── Permission selector (create page) ───────────────────────── */
.perm-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.perm-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.perm-option:has(input:checked) {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.04);
}

.perm-option input[type="radio"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: auto;
  padding: 0;
  border: none;
}

.perm-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.perm-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.perm-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* ── Seed file list (create page) ────────────────────────────── */
.seed-upload-area {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.seed-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.seed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.seed-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seed-item-size {
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}

.btn-icon:hover { color: var(--color-danger); background: #fef2f2; }

.form-hint-inline {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  font-weight: 400;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 400px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  header h1 { font-size: 1.3rem; }
}
