:root {
  --bg: #0f1420;
  --bg-elevated: #171e2e;
  --bg-card: #1c2436;
  --border: #2a3448;
  --text: #eef1f8;
  --text-muted: #9aa4bc;
  --accent: #6c5ce7;
  --accent-2: #00d4b8;
  --danger: #ff5470;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, #221a3d, #0f1420 60%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  max-width: 640px;
  margin: 0 auto;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.who-btn {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

.search-row { margin-bottom: 12px; }

input[type="search"],
input[type="text"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}

input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tab-row {
  display: flex;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 9px;
  padding: 9px 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  font-size: 0.95rem;
}

.card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.card-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.card-name {
  font-weight: 700;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-owner {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(0, 212, 184, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  font-size: 0.95rem;
}

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

.mine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.mine-name {
  font-size: 1.25rem;
  font-weight: 800;
}

.mine-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #8e7cf5);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.primary-btn:active { transform: scale(0.98); }

.ghost-btn {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 13px;
  font-weight: 600;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 10;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px;
}

.nav-btn.active { color: var(--accent-2); }
.nav-icon { font-size: 1.3rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.6);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.modal-sheet h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0 0 16px;
  line-height: 1.4;
}

.modal-sheet label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-sheet label input,
.modal-sheet label select {
  margin-top: 6px;
}

.optional { font-weight: 400; opacity: 0.7; }

.image-preview {
  margin-top: 10px;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -4px 0 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

@media (min-width: 480px) {
  .modal { align-items: center; }
  .modal-sheet { border-radius: 20px; max-height: 80vh; }
}
