/* ═══════════════════════════════════════════════
   COMPONENTS.CSS — minimalist, mobile-first
═══════════════════════════════════════════════ */

/* ── Top bar ────────────────────────────────── */
.top-bar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.top-bar-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

/* ── Wordmark — plain text, no styling that depends on the name ── */
.wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  user-select: none;
}

/* ── Bottom nav ─────────────────────────────── */
.bot-nav {
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--bot-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.bot-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
}
.bot-btn svg { transition: transform 0.15s; }
.bot-btn.active { color: var(--text); }
.bot-btn:active svg { transform: scale(0.88); }

/* ── Icon button ────────────────────────────── */
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.icon-btn:active { background: var(--bg-hi); }

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--r);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s;
}
.btn:active { opacity: 0.8; }

.btn-primary {
  background: var(--accent);
  color: var(--text-inv);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-md);
}
.btn-ghost:active { background: var(--bg-hi); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border-md);
}

.btn-sm  { font-size: 13px; padding: 8px 14px;  border-radius: var(--r-sm); }
.btn-md  { font-size: 14px; padding: 12px 18px; }
.btn-lg  { font-size: 15px; padding: 14px 22px; }
.btn-full { width: 100%; }

/* ── Fields ─────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.inp {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  color: var(--text);
  font-size: 15px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s;
}
.inp::placeholder { color: var(--text-4); }
.inp:focus { border-color: var(--border-hi); }

.inp-icon-wrap { position: relative; }
.inp-icon-wrap .inp { padding-left: 40px; }
.inp-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  pointer-events: none;
}

select.inp { appearance: none; cursor: pointer; }
textarea.inp { resize: vertical; min-height: 76px; line-height: 1.5; }

/* ── Checkbox row ───────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  padding: 12px 13px;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.check-row-label { display: flex; flex-direction: column; gap: 1px; }
.check-row-title { font-size: 14px; font-weight: 500; }
.check-row-sub   { font-size: 12px; color: var(--text-3); }

/* ── OAuth button ───────────────────────────── */
.oauth-btn {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.oauth-btn:active { background: var(--bg-hi); }

/* ── Overlay + modal ────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.overlay.open { opacity: 1; pointer-events: all; }

.modal {
  width: 100%;
  max-width: 540px;
  background: var(--modal-bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--border-md);
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.32,0.72,0,1);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.overlay.open .modal { transform: translateY(0); }

.modal-pill {
  width: 32px;
  height: 3px;
  background: var(--border-hi);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.modal-scroll {
  overflow-y: auto;
  scrollbar-width: none;
  flex: 1;
}
.modal-scroll::-webkit-scrollbar { display: none; }
.modal-body {
  padding: 12px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.modal-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-sub {
  font-size: 14px;
  color: var(--text-2);
  margin-top: -6px;
  margin-bottom: 4px;
}

/* ── Auth switch ────────────────────────────── */
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.auth-switch a {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid var(--border-hi);
}

/* ── Character card — horizontal ────────────── */
.char-card {
  width: 130px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  user-select: none;
  transition: background 0.15s;
}
.char-card:active { background: var(--bg-hi); }

.card-thumb {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 600;
  color: var(--text-4);
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 9px 9px 10px; }
.card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.card-desc {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 7px;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-4);
}
.card-chats { display: flex; align-items: center; gap: 3px; }

/* ── Character card — vertical (grid) ───────── */
.char-card-v {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: background 0.15s;
}
.char-card-v:active { background: var(--bg-hi); }
.card-thumb-v {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: var(--text-4);
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.card-body-v { padding: 9px 9px 10px; }
.card-name-v {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.card-desc-v {
  font-size: 11px;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 7px;
  line-height: 1.4;
  min-height: 31px;
}
.card-foot-v {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-4);
}

/* ── Section header ─────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 14px 8px;
}
.section-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}
.see-all {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  padding: 4px 0;
  flex-shrink: 0;
}

/* ── Avatar — neutral, just an initial ──────── */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  flex-shrink: 0;
}
.avatar-sm { width: 36px; height: 36px; font-size: 15px; border-radius: var(--r-sm); }
.avatar-md { width: 44px; height: 44px; font-size: 18px; border-radius: var(--r-sm); }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; border-radius: var(--r); }

/* ── Row item (my characters) ───────────────── */
.row-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 11px 11px 12px;
}
.row-item-info { flex: 1; min-width: 0; }
.row-item-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-item-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.row-item-actions { display: flex; gap: 5px; flex-shrink: 0; }
.action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-md);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.action-btn:active { background: var(--bg-hi); }
.action-btn.delete:active { color: var(--danger); }

/* ── Badge ──────────────────────────────────── */
.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-md);
}
.badge-pub  { background: var(--bg-hi); color: var(--text-2); }
.badge-priv { background: transparent;  color: var(--text-4); }

/* ── Dashed add button ──────────────────────── */
.dashed-btn {
  width: 100%;
  height: 46px;
  border-radius: var(--r);
  border: 1px dashed var(--border-hi);
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.dashed-btn:active { background: var(--bg-card); }

/* ── Sticky save bar ────────────────────────── */
.save-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  flex-shrink: 0;
}

/* ── Form grid ──────────────────────────────── */
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
