:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

/* ---------- Card page ---------- */
.page-card {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  display: flex;
  justify-content: center;
}
.card {
  width: 100%;
  max-width: 460px;
  margin: 20px 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.card__header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  padding: 32px 24px 28px;
  text-align: center;
}
.card__avatar {
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 32px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.card__name {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.card__subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  opacity: 0.9;
}

.card__section {
  padding: 20px 20px;
  border-top: 1px solid var(--border);
}
.card__section:first-of-type { border-top: 0; }
.section__title {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.contact { list-style: none; padding: 0; margin: 0; }
.row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row__icon {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.row__body { flex: 1; min-width: 0; }
.row__label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}
.row__value {
  font-size: 15px;
  word-break: break-word;
}
.row__value a { color: var(--text); }
.row__value a:hover { color: var(--accent); }

.sites { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.site {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.site:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.site__logo {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.site__body { flex: 1; min-width: 0; }
.site__name { font-size: 15px; font-weight: 600; }
.site__url { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.site__arrow { color: var(--text-muted); font-size: 18px; }

.card__footer {
  padding: 16px 20px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid var(--border);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(220, 38, 38, 0.3); }
.btn--danger:hover { background: rgba(220, 38, 38, 0.06); }

/* ---------- Empty / 404 ---------- */
.page-empty {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.empty {
  text-align: center;
  max-width: 400px;
}
.empty h1 { margin: 0 0 8px; font-size: 22px; }
.empty p { color: var(--text-muted); margin: 0; }
.empty code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 13px;
}

/* ---------- Admin ---------- */
.page-admin {
  min-height: 100dvh;
  padding: 24px 16px 64px;
  display: flex; justify-content: center;
}
.admin {
  width: 100%;
  max-width: 720px;
}
.admin__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.admin__title { margin: 0; font-size: 20px; }
.admin__logout {
  background: none; border: 0; color: var(--text-muted);
  font-size: 14px; cursor: pointer; padding: 4px 8px;
}
.admin__logout:hover { color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel__title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
}

.form { display: grid; gap: 12px; }
.form__row { display: grid; gap: 6px; }
.form__row--two {
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
@media (max-width: 480px) {
  .form__row--two { grid-template-columns: 1fr; }
}
.form label { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.06em; }
.form input, .form textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.form input:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.form textarea { resize: vertical; min-height: 68px; }
.form__actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 4px;
}

.hint { font-size: 12px; color: var(--text-muted); }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.cards__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
}
.cards__meta { min-width: 0; }
.cards__name { font-weight: 600; font-size: 15px; }
.cards__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cards__link {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  word-break: break-all;
}
.cards__actions { display: flex; gap: 6px; }
.cards__actions button {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.cards__actions .edit:hover { border-color: var(--accent); color: var(--accent); }
.cards__actions .copy:hover { border-color: var(--accent); color: var(--accent); }
.cards__actions .del:hover { border-color: var(--danger); color: var(--danger); }
.cards__empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.login {
  max-width: 360px;
  margin: 60px auto;
}
.login h1 { margin: 0 0 16px; font-size: 20px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  padding: 10px 16px;
  background: rgba(17, 24, 39, 0.9);
  color: #fff; font-size: 14px;
  border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; }
