:root {
  --primary: #E11D48;
  --primary-dark: #BE123C;
  --primary-soft: #FB7185;
  --accent: #2563EB;
  --bg: #FFF1F2;
  --fg: #881337;
  --muted: #9F5A6E;
  --card: #FFFFFF;
  --border: #FECDD3;
  --shadow: 0 10px 30px rgba(136, 19, 55, .12);
  --radius: 24px;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom));
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow-x: clip; }
html { scroll-padding-bottom: calc(64px + env(safe-area-inset-bottom) + 12px); }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .btn { font-family: 'Fredoka', sans-serif; }
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; touch-action: manipulation; }
img { max-width: 100%; }

/* ---------- Butoane ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 1rem; padding: 13px 26px; border-radius: 999px;
  min-height: 44px; text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 6px 18px rgba(225, 29, 72, .35); }
.btn-full { width: 100%; }
.btn-light { background: #fff; color: var(--primary); }
.btn-outline-light { border: 2px solid rgba(255, 255, 255, .7); color: #fff; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background .18s ease, transform .18s ease;
}
.icon-btn:active { transform: scale(.9); background: rgba(225, 29, 72, .08); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Autentificare ---------- */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 80% -10%, #FECDD3 0%, var(--bg) 55%);
}
.login-card {
  background: var(--card); border-radius: 32px; padding: 44px 30px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border);
  animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1);
}
.login-logo { width: 56px; height: 56px; margin-bottom: 18px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 10px; }
.login-card p { color: var(--muted); margin-bottom: 28px; font-size: .98rem; }
#google-btn { display: flex; justify-content: center; min-height: 44px; }
.login-error { color: #DC2626; margin-top: 14px; font-size: .9rem; }
.login-back { display: inline-block; margin-top: 22px; color: var(--muted); font-size: .9rem; text-decoration: none; }

/* ---------- Structură aplicație ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 241, 242, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.app-logo { display: flex; align-items: center; gap: 8px; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--fg); }
.app-logo svg { width: 26px; height: 26px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--primary-soft); object-fit: cover; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 8px 16px 0; padding: 12px 16px; border-radius: 16px;
  background: #DBEAFE; color: #1E3A8A; font-size: .9rem; font-weight: 600;
  animation: slide-down .35s ease;
}
.banner-btn { background: var(--accent); color: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .85rem; min-height: 36px; flex-shrink: 0; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.main { flex: 1; display: flex; flex-direction: column; padding-bottom: var(--tabbar-h); }
.view { flex: 1; display: flex; flex-direction: column; padding: 12px 16px 16px; max-width: 480px; width: 100%; margin: 0 auto; animation: view-in .3s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-title { font-size: 1.35rem; margin: 6px 2px 16px; }

/* ---------- Pachetul de carduri ---------- */
#view-deck { position: relative; }
.deck { position: relative; flex: 1; min-height: 420px; }
.card {
  position: absolute; inset: 0; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  touch-action: none; user-select: none; -webkit-user-select: none;
  will-change: transform;
  transition: transform .3s cubic-bezier(.2, 1.2, .4, 1), opacity .3s ease;
}
.card.dragging { transition: none; }
.card.top { cursor: grab; }
.card.top:active { cursor: grabbing; }
.card-img { flex: 1; background: #FFE4E6 center/cover no-repeat; min-height: 0; }
.card-body { padding: 16px 18px calc(16px + 6px); background: var(--card); }
.card-body h3 { font-size: 1.25rem; margin-bottom: 2px; }
.card-owner { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.card-owner img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.card-desc { color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-dist { display: inline-flex; align-items: center; gap: 4px; }
.card-dist svg { width: 14px; height: 14px; }

.stamp {
  position: absolute; top: 22px; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 1.5rem;
  padding: 6px 16px; border-radius: 12px; border: 3px solid; opacity: 0; pointer-events: none;
  background: rgba(255, 255, 255, .85);
}
.stamp.like { left: 18px; color: #059669; border-color: #059669; transform: rotate(-12deg); }
.stamp.nope { right: 18px; color: #E11D48; border-color: #E11D48; transform: rotate(12deg); }

.deck-actions { display: flex; justify-content: center; gap: 28px; padding: 18px 0 6px; }
.action-btn {
  width: 62px; height: 62px; border-radius: 50%; background: var(--card);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(136, 19, 55, .16);
  transition: transform .18s cubic-bezier(.2, 1.4, .4, 1), box-shadow .18s ease;
}
.action-btn:hover { transform: translateY(-3px); }
.action-btn:active { transform: scale(.88); }
.action-btn svg { width: 28px; height: 28px; }
.action-btn.nope { color: #94A3B8; }
.action-btn.like { color: var(--primary); }

/* ---------- Stări goale ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 20px; animation: pop-in .4s cubic-bezier(.2, 1.4, .4, 1); }
.empty svg { width: 56px; height: 56px; color: var(--primary-soft); margin-bottom: 16px; }
.empty h2 { font-size: 1.3rem; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 34ch; margin-bottom: 20px; font-size: .95rem; }
.radius-label { font-size: .9rem; font-weight: 700; color: var(--fg); margin-bottom: 18px; display: block; width: 100%; max-width: 280px; }
.radius-label input { width: 100%; margin-top: 8px; accent-color: var(--primary); }

/* ---------- Formular ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.photo-drop {
  position: relative; border: 2px dashed var(--border); border-radius: var(--radius);
  min-height: 200px; display: flex; align-items: center; justify-content: center;
  background: var(--card); cursor: pointer; overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
}
.photo-drop:active { transform: scale(.99); }
.photo-drop:hover { border-color: var(--primary-soft); }
.photo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; padding: 24px; text-align: center; }
.photo-placeholder svg { width: 42px; height: 42px; color: var(--primary-soft); }
#photo-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .92rem; }
.req { color: var(--primary); }
.field input, .field textarea {
  font: inherit; font-weight: 400; font-size: 1rem; padding: 13px 16px; border-radius: 16px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--fg);
  min-height: 44px; transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(225, 29, 72, .15); }
.field textarea { resize: vertical; }
.form-error { color: #DC2626; font-size: .9rem; font-weight: 700; }

/* ---------- Obiectele mele ---------- */
.mine-list { display: flex; flex-direction: column; gap: 12px; }
.mine-item {
  display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px; box-shadow: 0 4px 14px rgba(136, 19, 55, .06);
  animation: item-in .35s ease backwards;
}
.mine-item img { width: 74px; height: 74px; border-radius: 14px; object-fit: cover; background: #FFE4E6; flex-shrink: 0; }
.mine-item .info { flex: 1; min-width: 0; }
.mine-item strong { font-family: 'Fredoka', sans-serif; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine-item span { color: var(--muted); font-size: .85rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine-item .icon-btn { color: #DC2626; }
@keyframes item-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Trocuri ---------- */
.matches-list { display: flex; flex-direction: column; gap: 14px; }
.match-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 4px 14px rgba(136, 19, 55, .06); animation: item-in .35s ease backwards;
}
.match-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.match-head img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-soft); }
.match-head strong { font-family: 'Fredoka', sans-serif; font-size: 1.1rem; display: block; }
.match-head a { color: var(--accent); font-size: .88rem; text-decoration: none; word-break: break-all; }
.match-items { display: flex; flex-direction: column; gap: 8px; font-size: .88rem; color: var(--muted); }
.match-items .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.match-items img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.match-items .who { font-weight: 800; color: var(--fg); min-width: 84px; }

/* ---------- Navigație ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  position: relative; flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: 14px; color: var(--muted);
  font-size: .72rem; font-weight: 700; min-height: 48px;
  transition: color .2s ease, transform .15s ease;
}
.tab:active { transform: scale(.92); }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--primary); }
.badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  background: var(--primary); color: #fff; font-size: .65rem; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
  animation: pop-in .3s cubic-bezier(.2, 1.6, .4, 1);
}

/* ---------- Suprapunere Troc ---------- */
.match-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, rgba(225, 29, 72, .96), rgba(159, 18, 57, .96));
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade-in .3s ease;
}
.match-box { text-align: center; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 14px; animation: pop-in .5s cubic-bezier(.2, 1.5, .4, 1); }
.match-icon { width: 74px; height: 74px; animation: spin-once .7s cubic-bezier(.2, 1.2, .4, 1); }
.match-box h2 { font-size: 2.2rem; }
.match-box p { opacity: .9; max-width: 30ch; }
.match-box .btn { min-width: 230px; }
@keyframes spin-once { from { transform: rotate(-180deg) scale(.4); } to { transform: rotate(0) scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px); transform: translateX(-50%);
  background: var(--fg); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 700; z-index: 90; box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
  animation: toast-in .3s cubic-bezier(.2, 1.4, .4, 1); max-width: calc(100vw - 40px); text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Poze multiple pe card ---------- */
.card-dots { position: absolute; top: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; z-index: 2; }
.card-dots span { width: 26px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .45); transition: background .2s ease; }
.card-dots span.on { background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.card-cond {
  position: absolute; top: 20px; right: 14px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: .78rem;
  padding: 5px 12px; border-radius: 999px; color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.card-cond svg { width: 14px; height: 14px; }
.card-cond.nou { background: rgba(5, 150, 105, .85); }
.card-cond.uzat { background: rgba(136, 19, 55, .6); }

/* ---------- Toggle stare (nou/uzat) ---------- */
.condition-group { border: none; display: flex; flex-direction: column; gap: 6px; }
.condition-group legend { font-weight: 700; font-size: .92rem; margin-bottom: 6px; padding: 0; }
.condition-toggle { display: flex; gap: 10px; }
.condition-option { flex: 1; }
.condition-option input { position: absolute; opacity: 0; pointer-events: none; }
.condition-chip {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 10px; border-radius: 16px; min-height: 48px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--muted);
  font-family: 'Fredoka', sans-serif; font-weight: 600; cursor: pointer;
  transition: all .2s cubic-bezier(.2, 1.2, .4, 1);
}
.condition-chip svg { width: 20px; height: 20px; }
.condition-option input:checked + .condition-chip {
  border-color: var(--primary); color: var(--primary);
  background: #FFF1F2; box-shadow: 0 0 0 3px rgba(225, 29, 72, .12);
  transform: scale(1.02);
}
.condition-option input:focus-visible + .condition-chip { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Thumbs poze în formular ---------- */
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; width: 100%; }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: 14px; overflow: hidden; animation: pop-in .25s cubic-bezier(.2, 1.4, .4, 1); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
}
.photo-thumb-add {
  width: 84px; height: 84px; border-radius: 14px; border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--primary-soft); font-size: 28px;
}

/* ---------- Clopoțel + panou notificări ---------- */
#bell-btn { position: relative; }
.bell-badge { top: 4px; right: 2px; }
.notif-panel {
  position: fixed; top: calc(56px + env(safe-area-inset-top)); right: 12px; z-index: 60;
  width: min(340px, calc(100vw - 24px)); max-height: 60dvh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 18px 44px rgba(136, 19, 55, .22); padding: 16px;
  animation: pop-in .25s cubic-bezier(.2, 1.4, .4, 1); transform-origin: top right;
}
.notif-panel h3 { font-size: 1.05rem; margin-bottom: 10px; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-top: 1px solid var(--border); font-size: .9rem; }
.notif-item:first-of-type { border-top: none; }
.notif-item svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.notif-item.unread { font-weight: 800; }
.notif-item time { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.notif-empty { color: var(--muted); font-size: .9rem; }

/* ---------- Chat ---------- */
.chat-screen {
  position: fixed; inset: 0; z-index: 80; background: var(--bg);
  display: flex; flex-direction: column;
  animation: chat-in .3s cubic-bezier(.2, 1.1, .4, 1);
}
@keyframes chat-in { from { transform: translateX(100%); } to { transform: none; } }
.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(255, 241, 242, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.chat-header img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-soft); }
.chat-header strong { font-family: 'Fredoka', sans-serif; font-size: 1.05rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 78%; padding: 10px 14px; border-radius: 18px; font-size: .95rem;
  animation: msg-in .25s cubic-bezier(.2, 1.3, .4, 1);
  overflow-wrap: break-word;
}
.msg.mine { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-bottom-right-radius: 6px; }
.msg.theirs { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg time { display: block; font-size: .68rem; opacity: .65; margin-top: 3px; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.chat-form {
  display: flex; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1; font: inherit; font-size: 1rem; padding: 12px 16px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--fg); min-height: 44px;
}
.chat-form input:focus { outline: none; border-color: var(--primary); }
.chat-send {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.chat-send:active { transform: scale(.88); }
.chat-send svg { width: 20px; height: 20px; }

.give-btn {
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: .78rem;
  color: #059669; background: #ECFDF5; border: 1.5px solid #A7F3D0;
  border-radius: 999px; padding: 5px 12px; min-height: 32px;
  transition: transform .15s ease, background .2s ease;
}
.give-btn:active { transform: scale(.92); }

/* ---------- Buton chat pe cardul de troc ---------- */
.match-chat-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  background: #FFF1F2; color: var(--primary); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: .85rem;
  min-height: 40px; position: relative;
  transition: transform .15s ease, background .2s ease;
}
.match-chat-btn:active { transform: scale(.93); }
.match-chat-btn svg { width: 17px; height: 17px; }
.match-chat-btn .badge { position: static; margin-left: 2px; }

@media (min-width: 640px) {
  .deck { min-height: 520px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
