:root {
  --bg: #120c1b;
  --bg-1: #180f24;
  --bg-2: #1f1330;
  --ink: #f4eefb;
  --ink-dim: #b9aecb;
  --ink-faint: #786d8f;
  --pink: #ff5c8d;
  --pink-deep: #e33e78;
  --purple: #9a4de0;
  --blue: #4f8ce8;
  --online: #8ee6b1;
  --danger: #ff8aa9;
  --line: rgba(244, 238, 251, 0.12);
  --line-strong: rgba(244, 238, 251, 0.24);
  --surface: rgba(24, 15, 36, 0.82);
  --surface-strong: rgba(31, 19, 48, 0.92);
  --input: rgba(18, 12, 27, 0.9);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 92, 141, 0.22), transparent 34rem),
    radial-gradient(circle at 90% 20%, rgba(79, 140, 232, 0.20), transparent 30rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--pink); }
button, input, textarea { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}
button:active { transform: scale(0.98); }
button:disabled { cursor: not-allowed; opacity: 0.65; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.55rem; line-height: 1.05; }
h2 { margin-bottom: 14px; font-size: 1.15rem; }
h3 { margin-bottom: 6px; }

.app-shell, .auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page-shell {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 16px 16px 92px;
}

.hero, .auth-card, .panel, .companion-card, .match-item, .match-row {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero {
  width: min(480px, 100%);
  padding: 34px 28px;
  border-radius: var(--radius);
}

.hero__brand, .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.hero__logo { width: 82px; height: 82px; object-fit: contain; }
.mini-logo { width: 46px; height: 46px; object-fit: contain; }
.auth-logo { width: 82px; height: 82px; object-fit: contain; margin-bottom: 10px; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--ink-dim);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero__content h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 10vw, 3.8rem);
  line-height: 0.98;
}
.hero__content p, .meta, .muted-link, .empty-state { color: var(--ink-dim); }

.hero-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 32px;
  border-radius: var(--radius);
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--pink); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

.primary-btn, .ghost-btn, .send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-weight: 700;
}

.primary-btn {
  color: #120c1b;
  background: linear-gradient(100deg, var(--pink), var(--purple) 52%, var(--blue));
}

.ghost-btn {
  color: var(--ink);
  background: transparent;
  border-color: var(--line-strong);
}

.form-message {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}
.form-message[data-type="success"] { color: var(--online); }

.card-stack, .list-stack {
  display: grid;
  gap: 18px;
}

.companion-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  min-height: clamp(470px, 78vh, 640px);
}

.companion-card__image,
.companion-card img {
  width: 100%;
  height: clamp(470px, 78vh, 640px);
  object-fit: cover;
  display: block;
  background: var(--surface-strong);
}

.companion-card__image--placeholder {
  width: 100%;
  height: clamp(470px, 78vh, 640px);
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  background: linear-gradient(135deg, rgba(255, 92, 141, 0.12), rgba(79, 140, 232, 0.14));
}

.companion-card__info {
  position: absolute;
  left: 14px;
  right: 14px;
  z-index: 2;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(18, 12, 27, 0.62);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(18px);
}

.companion-card__info--top {
  top: 14px;
}

.companion-card__info--bottom {
  bottom: 14px;
}

.companion-card__name {
  font-size: 1.45rem;
  line-height: 1.05;
  font-weight: 800;
}

.companion-card__meta {
  margin-top: 4px;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.companion-card__bio {
  margin: 0;
  color: rgba(244, 238, 251, 0.88);
}

.companion-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 0 0;
}

.btn-pass, .btn-like {
  min-height: 54px;
  border-radius: 999px;
  font-size: 1.35rem;
  font-weight: 800;
}

.btn-pass {
  color: var(--ink-dim);
  background: var(--input);
  border: 1px solid var(--line);
}

.btn-like {
  color: #120c1b;
  background: linear-gradient(100deg, var(--pink), var(--purple) 58%, var(--blue));
}

.btn-like.is-matched {
  color: var(--ink-dim);
  background: var(--input);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

.match-item, .match-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  color: inherit;
}

.match-item:hover, .match-row:hover { border-color: var(--pink); }

.match-avatar, .match-row img, .chat-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--input);
}

.match-info, .match-row span {
  min-width: 0;
}

.match-name, .match-row strong {
  display: block;
  font-weight: 750;
}

.match-preview, .match-row small {
  display: block;
  margin-top: 3px;
  color: var(--ink-dim);
  font-size: 0.87rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-time {
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.match-card {
  position: relative;
  min-height: clamp(470px, 78vh, 640px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.match-card__image {
  width: 100%;
  height: clamp(470px, 78vh, 640px);
  display: block;
  object-fit: cover;
  background: var(--surface-strong);
}

.match-card__image--placeholder {
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  background: linear-gradient(135deg, rgba(255, 92, 141, 0.12), rgba(79, 140, 232, 0.14));
}

.match-card__panel {
  position: absolute;
  left: 14px;
  right: 14px;
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(18, 12, 27, 0.62);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(18px);
}

.match-card__panel--top { top: 14px; }
.match-card__panel--bottom { bottom: 14px; }

.match-card__panel strong {
  font-size: 1.25rem;
  line-height: 1.05;
}

.match-card__panel small {
  color: rgba(244, 238, 251, 0.88);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.match-card__action {
  justify-self: start;
  margin-top: 8px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 16px;
  color: #120c1b;
  font-weight: 800;
  background: linear-gradient(100deg, var(--pink), var(--purple) 58%, var(--blue));
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--line);
  background: rgba(18, 12, 27, 0.94);
  backdrop-filter: blur(16px);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav a {
  display: flex;
  min-width: 84px;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: var(--ink-dim);
  font-size: 0.72rem;
  font-weight: 700;
}

.bottom-nav a.active { color: var(--pink); }
.nav-icon { font-size: 1.25rem; line-height: 1; }

.chat-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 48px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 12, 27, 0.94);
  backdrop-filter: blur(16px);
}
.chat-header h1 { font-size: 1.05rem; }
.chat-header p { margin: 2px 0 0; color: var(--online); font-size: 0.78rem; }
.back-link { color: var(--ink-dim); font-weight: 800; }
.chat-avatar { width: 48px; height: 48px; }

.messages {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  max-width: 78%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  word-break: break-word;
}
.message.user {
  align-self: flex-end;
  color: #fff;
  border-color: transparent;
  border-bottom-right-radius: 4px;
  background: linear-gradient(100deg, rgba(255, 92, 141, 0.78), rgba(154, 77, 224, 0.74));
}
.message.companion {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.message.system {
  align-self: center;
  max-width: 92%;
  color: var(--ink-dim);
  text-align: center;
}
.message p { margin-bottom: 5px; }
.message time { color: rgba(244, 238, 251, 0.68); font-size: 0.72rem; }

.typing-indicator {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  background: var(--surface);
}
.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-dim);
  animation: typing 1s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(18, 12, 27, 0.94);
}
.chat-form textarea {
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: 22px;
}
.send-btn {
  min-width: 64px;
  height: 44px;
  border-radius: 999px;
  color: #120c1b;
  background: var(--pink);
}

.quota {
  display: grid;
  gap: 10px;
}
.quota div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(244, 238, 251, 0.12);
}
.quota i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(100deg, var(--pink), var(--blue));
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
  border-radius: var(--radius);
}

.empty-state {
  padding: 56px 20px;
  text-align: center;
}

.empty-state__icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--pink);
  border: 1px solid var(--line-strong);
  background: rgba(255, 92, 141, 0.08);
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.hidden { display: none !important; }

@media (min-width: 760px) {
  .page-shell {
    padding-top: 28px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 16px;
    width: min(520px, calc(100% - 28px));
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
  }

  .bottom-nav a.active {
    border-radius: var(--radius-sm);
    background: linear-gradient(100deg, rgba(255, 92, 141, 0.18), rgba(79, 140, 232, 0.18));
  }
}
