/* Goat Sender root visual styling — glass morphism, dark theme, purple accent. */
:root {
  --color-bg: #10091b;
  --color-text: #ffffff;
  --color-accent: #b56cff;
  --color-accent-dim: rgba(181, 108, 255, .2);
  --color-gray: #666666;
  --color-gray-light: #999999;
  --color-border: rgba(255, 255, 255, .1);
  --color-danger: #ff4d4d;
  --safe-area-inset-top: 0px;
  --safe-area-inset-bottom: 0px;
  --app-height: 100vh;
  --navbar-height: 72px;
  --glass-bg: rgba(255, 255, 255, .08);
  --glass-bg-elevated: rgba(255, 255, 255, .12);
  --glass-border: rgba(255, 255, 255, .15);
  --glass-border-light: rgba(255, 255, 255, .25);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, .25);
  --glass-blur: 20px;
  --glass-blur-strong: 24px;
  --border-radius: 12px;
  --border-radius-full: 9999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #b56cff -163.91%, #10091b 55.2%);
  color: var(--color-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: var(--app-height, 100vh);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* --- scroll root --- */
.app-root {
  min-height: var(--app-height, 100vh);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* --- ambient orbs (background) --- */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.ambient__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .35;
}
.ambient__orb--accent { width: 320px; height: 320px; background: #b56cff; top: -120px; right: -80px; }
.ambient__orb--blue   { width: 260px; height: 260px; background: #c084fc; top: 20%; left: -120px; opacity: .18; }

/* --- layout scaffolding --- */
.page {
  position: relative;
  z-index: 1;
  padding: 20px 16px calc(var(--navbar-height) + 24px);
}

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 24px; font-weight: 700; margin: 0; }

.back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--glass-border-light);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  flex-shrink: 0;
}

/* --- glass cards --- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(1.2);
  box-shadow: var(--glass-shadow);
}
.glass-border-light { border-color: var(--glass-border-light); }

.card { padding: 16px; }

/* --- dashboard cards (home) --- */
.dashboard-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  width: 100%;
  text-align: left;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.dashboard-card:hover { background: var(--glass-bg-elevated); }

/* --- forms --- */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 13px;
  color: rgba(255,255,255,.6);
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: rgba(255,255,255,.35); }
.input::placeholder, .textarea::placeholder { color: rgba(255,255,255,.3); }
.textarea { min-height: 90px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; }
.select option { background: #21152f; color: #fff; }

/* --- buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, opacity .15s, background .15s;
  outline: none;
  color: #fff;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  color: #10091b;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover:not(:disabled) { opacity: .9; }

.btn-secondary {
  background: rgba(255,255,255,.1);
  border: 1px solid var(--glass-border-light);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,.18); }

.btn-danger {
  background: rgba(255,77,77,.12);
  color: var(--color-danger);
  border: 1px solid rgba(255,77,77,.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(255,77,77,.22); }

.btn-ghost { background: transparent; color: rgba(255,255,255,.7); }
.btn-ghost:hover { color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* --- toggle switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 46px; height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.14);
  border-radius: 9999px;
  cursor: pointer;
  transition: background .16s;
}
.switch__slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: left .16s;
}
.switch input:checked + .switch__slider { background: var(--color-accent-dim); }
.switch input:checked + .switch__slider::before { left: 23px; background: var(--color-accent); }

/* --- list rows --- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.row__body { flex: 1; min-width: 0; }
.row__title { font-size: 15px; font-weight: 600; }
.row__subtitle { font-size: 13px; color: rgba(255,255,255,.55); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Строка слота: текст на всю ширину, кнопки — отдельной строкой ниже. */
.row--slot {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.row--slot .row__body { flex: none; }
.row--slot .row__subtitle {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}
.row--slot .row__actions { width: 100%; flex-shrink: 0; }
.row--slot .row__actions .btn { flex: 1; }

/* --- badges / chips --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--glass-border);
  color: rgba(255,255,255,.75);
}
.chip--accent { background: var(--color-accent-dim); color: var(--color-accent); border-color: transparent; }

/* --- empty state --- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
}
.empty__icon {
  width: 56px; height: 56px;
  border-radius: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border-light);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  font-size: 24px;
}
.empty__title { font-size: 15px; font-weight: 600; color: rgba(255,255,255,.5); }
.empty__subtitle { font-size: 13px; color: rgba(255,255,255,.3); margin: 4px 0 16px; }

/* --- bottom navigation --- */
.navbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(9,9,9,.7);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-top: 1px solid var(--glass-border);
  padding-bottom: max(8px, var(--safe-area-inset-bottom));
  z-index: 50;
}
.navbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 6px;
  color: rgba(255,255,255,.45);
  font-size: 11px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.navbar__item svg { width: 22px; height: 22px; }
.navbar__item--active { color: var(--color-accent); }

/* --- toast --- */
.toast-wrap {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  pointer-events: none;
  z-index: 9999;
}
.toast {
  background: #21152f;
  color: #fff;
  border: 1px solid var(--glass-border-light);
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
  animation: toast-in .3s ease-out;
  max-width: 92vw;
}
.toast--error { border-color: rgba(255,77,77,.5); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- modal dialog --- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: #21152f;
  border: 1px solid var(--glass-border-light);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  animation: modal-in .25s ease-out;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal__close { background: rgba(255,255,255,.1); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; }
@keyframes modal-in {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- misc helpers --- */
.text-muted { color: rgba(255,255,255,.55); }
.text-accent { color: var(--color-accent); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }
.section-title { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }

/* auth screen */
.auth-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.auth-screen h1 { font-size: 26px; font-weight: 700; margin: 16px 0 8px; }
.auth-screen p { color: rgba(255,255,255,.6); font-size: 14px; margin: 0 0 24px; }

/* --- messenger: chat list --- */
.row--chat { justify-content: flex-start; cursor: pointer; text-align: left; width: 100%; color: #fff; }
.row--chat:hover { background: rgba(255,255,255,.09); }

.chat-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border-light);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar--placeholder { font-size: 20px; color: rgba(255,255,255,.55); }

.unread-badge {
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--color-accent);
  color: #10091b;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* --- SPA view container --- */
.view { min-height: var(--app-height, 100vh); }

/* --- messenger: chat view --- */
.chat {
  position: relative;
  width: 100%;
  height: 100vh;
  height: var(--app-height, 100vh);
  display: flex;
  flex-direction: column;
  background: #120a1e;
}
/* В режиме чата скрываем нижнюю навигацию — это полноэкранная переписка. */
body.view-chat .navbar { display: none; }
.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(9,9,9,.7);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat__head-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat__title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__subtitle { font-size: 12px; color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

.bubble { max-width: 78%; display: flex; flex-direction: column; }
.bubble--in { align-self: flex-start; align-items: flex-start; }
.bubble--out { align-self: flex-end; align-items: flex-end; }
.bubble__text {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.bubble--in .bubble__text {
  background: rgba(255,255,255,.1);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}
.bubble--out .bubble__text {
  background: var(--color-accent);
  color: #10091b;
  border-bottom-right-radius: 4px;
}
.bubble__time { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 4px; padding: 0 4px; }

.chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, var(--safe-area-inset-bottom));
  background: rgba(9,9,9,.7);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat__input {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  font-family: inherit;
}
.chat__input::placeholder { color: rgba(255,255,255,.3); }
.chat__send {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: #10091b;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat__send:active { transform: scale(.95); }

/* --- chat with email highlight --- */
.row--has-email {
  background: rgba(255, 217, 102, .14);
  border-color: rgba(255, 217, 102, .45);
}
.row--has-email:hover { background: rgba(255, 217, 102, .2); }
.row--has-email .row__title { color: #ffd966; }
