:root {
  --bg: #0e0f11;
  --surface: #17181c;
  --surface2: #1e2025;
  --border: #2a2c33;
  --border-focus: #5b8aff;
  --text: #e4e5e9;
  --text-dim: #8b8d97;
  --accent: #5b8aff;
  --accent-glow: rgba(91, 138, 255, 0.15);
  --green: #4ade80;
  --red: #f87171;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91,138,255,0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(74,222,128,0.04), transparent);
}

.container {
  max-width: 520px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
}

header h1 span { color: var(--accent); }

header p {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 300;
}

.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 0.6rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-dim);
  user-select: none;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(91,138,255,0.3);
}

.tab .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 0.7rem;
  margin-right: 6px;
  background: rgba(255,255,255,0.1);
  font-family: 'JetBrains Mono', monospace;
}

.tab.active .num { background: rgba(255,255,255,0.25); }

.panel { display: none; animation: fadeIn 0.25s ease; }
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.field input, .field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus, .field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder, .field textarea::placeholder {
  color: #50525a;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

.row { display: flex; gap: 0.75rem; }
.row .field { flex: 1; }

/* Field remove button */
.field-remove {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
  margin-left: auto;
}

.field-remove:hover {
  opacity: 1;
  color: var(--red);
}

/* Share panel */
.share-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background 0.15s;
  cursor: pointer;
}

.share-item:hover { background: var(--surface2); }

.share-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s;
}

.share-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.share-item input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.share-label { flex: 1; }

.share-label .key {
  font-size: 0.82rem;
  font-weight: 500;
}

.share-label .val {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 1px;
  word-break: break-all;
}

.share-label .empty {
  color: #50525a;
  font-style: italic;
  font-family: 'DM Sans', sans-serif;
}

.select-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.select-controls button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  padding: 0;
}

.select-controls button:hover { text-decoration: underline; }

/* QR section */
.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
}

.qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  cursor: pointer;
}

.qr-box canvas, .qr-box img { display: block; border-radius: 4px; }

.qr-empty {
  width: 200px; height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  color: #bbb;
  font-size: 0.82rem;
  text-align: center;
}

.qr-empty svg { opacity: 0.4; }

.qr-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

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

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

.btn-primary:hover {
  background: #4a7aef;
  box-shadow: 0 2px 16px rgba(91,138,255,0.3);
}

.vcard-preview {
  width: 100%;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow-y: auto;
}

.field-count {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
}

.field-count strong { color: var(--green); }

/* Field picker modal */
.field-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.field-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 1.25rem;
  width: 100%;
  max-width: 520px;
  max-height: 70vh;
  overflow-y: auto;
}

.field-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.field-picker-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.field-picker-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.field-picker-category {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 1rem 0 0.5rem;
}

.field-picker-category:first-of-type {
  margin-top: 0;
}

.field-picker-item {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.field-picker-item:hover {
  background: var(--surface2);
}

/* Profile bar */
.profile-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  margin-bottom: 1rem;
  scrollbar-width: none;
}

.profile-bar::-webkit-scrollbar { display: none; }

.profile-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.profile-pill-add {
  background: transparent;
  border-style: dashed;
  color: var(--accent);
  font-size: 1rem;
  padding: 6px 12px;
}

/* Profile context menu */
.profile-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.profile-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 140px;
  z-index: 201;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.profile-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.profile-menu-item:hover {
  background: var(--surface2);
}

.profile-menu-item.danger {
  color: var(--red);
}

/* New profile dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
}

.dialog h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.dialog input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  outline: none;
  margin-bottom: 1rem;
}

.dialog input[type="text"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 1rem;
}

.preset-btn {
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

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

.preset-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Quick-show overlay */
.quick-show-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.quick-show-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  padding: 1rem;
}

.quick-show-qr {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 40px rgba(91, 138, 255, 0.2);
}

.quick-show-name {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 500;
}

.quick-show-hint {
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
}

/* Share view */
.share-view {
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.share-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
}

.share-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.share-card .share-title {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.share-fields {
  text-align: left;
  margin-bottom: 1.5rem;
}

.share-field {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.share-field:last-child {
  border-bottom: none;
}

.share-field-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  width: 80px;
}

.share-field-value {
  font-size: 0.88rem;
  word-break: break-all;
}

.share-field-value a {
  color: var(--accent);
  text-decoration: none;
}

.share-field-value a:hover {
  text-decoration: underline;
}

.share-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.share-qr {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.share-qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
}

.share-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

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

.share-error a:hover {
  text-decoration: underline;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-size: 0.82rem;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 2000;
  animation: fadeIn 0.15s ease;
}

@media (max-width: 500px) {
  .row { flex-direction: column; gap: 0; }
  body { padding: 1rem 0.75rem; }
}
