:root {
  --sea-deep: #0b4f6c;
  --sea: #1789a6;
  --turquoise: #21c0c7;
  --turquoise-soft: #7fd8d6;
  --sand: #e9d8a6;
  --sand-deep: #d9b671;
  --ochre: #c99446;
  --foam: #f4fbfb;
  --ink: #0d2b36;
  --white: #ffffff;
  --shadow: 0 20px 50px rgba(11, 79, 108, 0.25);
  --shadow-sm: 0 8px 24px rgba(11, 79, 108, 0.15);
  --radius: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #cdeef2 0%, #8ed6dd 35%, #3ba7bc 70%, var(--sea) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Солнечный блик сверху */
body::before {
  content: '';
  position: fixed;
  top: -120px; right: -80px;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(255,241,199,0.85) 0%, rgba(255,241,199,0) 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 .4em;
}

.wrap {
  position: relative;
  z-index: 2;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 20px 220px;
  min-height: 100vh;
}

/* ---------- Карточка ---------- */
.card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 30px;
  border: 1px solid rgba(255,255,255,0.6);
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}
.brand .sail { font-size: 42px; display: block; margin-bottom: 6px; }
.brand h1 {
  font-size: clamp(28px, 6vw, 40px);
  color: var(--sea-deep);
}
.brand p {
  color: #35606e;
  font-size: 16px;
  margin: 0;
  line-height: 1.5;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 14px 22px;
  border-radius: 16px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
  width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--sea) 0%, var(--turquoise) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(23,137,166,.35); }
.btn-ghost {
  background: transparent;
  color: var(--sea-deep);
  border: 2px dashed var(--turquoise-soft);
}
.btn-sand {
  background: linear-gradient(135deg, var(--sand-deep), var(--ochre));
  color: #4a2f0a;
}

.login-box { text-align: center; }
.login-box .tg-widget { display: flex; justify-content: center; margin: 8px 0; min-height: 48px; }
.login-box a.btn { text-decoration: none; margin-top: 10px; }
.dev-note { font-size: 13px; color: #5a7a84; margin-top: 14px; }

/* ---------- Приветствие ---------- */
.greeting {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e2eef0;
}
.greeting img, .greeting .avatar-fallback {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--turquoise-soft);
}
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--turquoise-soft);
  color: #fff; font-size: 24px; font-weight: 700;
}
.greeting .hi { font-size: 20px; font-weight: 800; color: var(--sea-deep); }
.greeting .sub { font-size: 13px; color: #6a8a92; }

/* ---------- Форма ---------- */
.field { margin-bottom: 22px; }
.field > label.title {
  display: block;
  font-weight: 800;
  color: var(--sea-deep);
  margin-bottom: 8px;
  font-size: 15px;
}
.hint { font-size: 13px; color: #6a8a92; margin: 4px 0 0; }

.date-row { display: flex; gap: 10px; }
select, input[type="number"] {
  font: inherit;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1.5px solid #cfe3e6;
  background: #fbfefe;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
select:focus, input:focus { border-color: var(--turquoise); }
.date-row select { flex: 1; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  margin-top: 12px;
  font-size: 14px;
  color: #35606e;
}
.toggle input { display: none; }
.switch {
  width: 44px; height: 26px;
  background: #cfe3e6;
  border-radius: 999px;
  position: relative;
  transition: background .2s;
  flex: 0 0 auto;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .switch { background: var(--turquoise); }
.toggle input:checked + .switch::after { transform: translateX(18px); }

.year-input { margin-top: 12px; }
.year-input input { width: 130px; }

/* Строки именин (несколько дат) */
.nameday-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.nameday-row select { flex: 1; }
.nameday-rm {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 1.5px solid #f0c9c2; background: #fdf0ee; color: #b4321f;
  border-radius: 12px; font-size: 16px; cursor: pointer; line-height: 1;
}
.nameday-rm:hover { background: #fbe3df; }
.btn-add {
  background: transparent; color: var(--sea); border: 2px dashed var(--turquoise-soft);
  border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer;
  width: 100%; margin-top: 4px;
}
.btn-add:hover { background: rgba(33,192,199,.08); }

/* ---------- Вкладки портала ---------- */
.tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
  background: #eef6f7; padding: 5px; border-radius: 14px;
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 10px 6px; border-radius: 10px; font: inherit; font-weight: 700;
  color: #35606e; font-size: 14px; transition: background .15s, color .15s;
}
.tab.active { background: #fff; color: var(--sea-deep); box-shadow: var(--shadow-sm); }

/* ---------- Вишлист ---------- */
.wish-add { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.wish-add input {
  font: inherit; padding: 11px 12px; border: 1.5px solid #cfe3e6;
  border-radius: 12px; background: #fbfefe; width: 100%;
}
.wish-add input:focus { outline: none; border-color: var(--turquoise); }

.wish-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: #fbfefe; border: 1.5px solid #e2eef0;
  border-radius: 12px; margin-bottom: 8px;
}
.wish-item .info { flex: 1; min-width: 0; }
.wish-item .info strong { color: var(--ink); display: block; }
.wish-item .info a { color: var(--sea); font-size: 13px; word-break: break-all; }
.wish-item .info .note { font-size: 13px; color: #6a8a92; margin-top: 2px; }
.wish-item .rm {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid #f0c9c2; background: #fdf0ee; color: #b4321f; cursor: pointer; font-size: 15px;
}
.wish-empty { font-size: 14px; color: #6a8a92; padding: 6px 0 10px; }

.btn-reserve {
  border: none; border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 700;
  cursor: pointer; font-size: 13px; white-space: nowrap; flex: 0 0 auto;
}
.btn-reserve.free { background: linear-gradient(135deg, var(--sand-deep), var(--ochre)); color: #4a2f0a; }
.btn-reserve.mine { background: #e6f6ec; color: #1c6b3a; border: 1.5px solid #b7e3c6; }
.btn-reserve.taken { background: #eef1f2; color: #8aa0a6; cursor: default; }

/* ---------- Календарь ---------- */
.cal-month { margin-bottom: 18px; }
.cal-month h3 {
  font-size: 16px; color: var(--sea-deep); margin: 0 0 8px;
  border-bottom: 2px solid #e2eef0; padding-bottom: 6px; text-transform: capitalize;
}
.cal-month.current h3 { color: var(--ochre); border-color: var(--sand-deep); }
.cal-entry { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; }
.cal-entry.today { background: #fff7e6; }
.cal-day { flex: 0 0 auto; width: 30px; text-align: center; font-weight: 800; color: var(--ochre); }
.cal-entry .who { font-weight: 600; }
.cal-entry .kind { margin-left: auto; font-size: 13px; color: #6a8a92; }
.cal-empty { color: #9ab; font-size: 13px; padding: 4px 6px; }

/* ---------- Друзья ---------- */
.friend {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fbfefe; border: 1.5px solid #e2eef0; border-radius: 14px;
  margin-bottom: 8px; cursor: pointer; transition: border-color .15s;
}
.friend:hover { border-color: var(--turquoise-soft); }
.friend .avatar-mini {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--turquoise-soft); color: #fff; font-weight: 700; font-size: 18px;
}
.friend .fmeta { flex: 1; min-width: 0; }
.friend .fname { font-weight: 700; color: var(--sea-deep); }
.friend .fsub { font-size: 13px; color: #6a8a92; }
.friend .badge {
  margin-left: auto; background: var(--turquoise-soft); color: #06525a;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.back-link { background: none; border: none; color: var(--sea); font: inherit; font-weight: 700; cursor: pointer; padding: 0 0 12px; }
.friend-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.friend-head .avatar-mini { width: 52px; height: 52px; font-size: 22px; }
.friend-head .fname { font-size: 18px; font-weight: 800; color: var(--sea-deep); }
.friend-head .fsub { font-size: 13px; color: #6a8a92; }

/* ==================== ПРИЛОЖЕНИЕ (портал) ==================== */
.app {
  position: fixed; inset: 0; max-width: 600px; margin: 0 auto; z-index: 5;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #f6fcfc 0%, #e9f5f6 100%);
}
.app-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
}
.view-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(22px, 6vw, 28px); color: var(--sea-deep); margin: 0;
}
.view-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
.back-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px;
  border: 1.5px solid #dceef0; background: #fff; color: var(--sea);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .12s ease, background .15s ease;
}
.back-btn svg { width: 22px; height: 22px; }
.back-btn:active { transform: scale(.9); }
.back-btn:hover { background: #f3fbfb; }

/* Пейджер календаря */
.cal-pager { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-nav {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px;
  border: 1.5px solid #dceef0; background: #fff; color: var(--sea);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .12s ease, background .15s ease;
}
.cal-nav svg { width: 22px; height: 22px; }
.cal-nav:active { transform: scale(.9); }
.cal-nav:hover { background: #f3fbfb; }
.cal-month-label {
  flex: 1; text-align: center; font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700; color: var(--sea-deep); text-transform: capitalize;
}
#calendar.slide-left { animation: slideLeft .25s ease; }
#calendar.slide-right { animation: slideRight .25s ease; }
@keyframes slideLeft { from { opacity: .3; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slideRight { from { opacity: .3; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

/* Сетка календаря */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: #fff; border: 1.5px solid #e6f1f2; border-radius: 16px; padding: 12px 10px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.cal-wd { text-align: center; font-size: 11px; font-weight: 700; color: #7aa0a8; padding-bottom: 6px; }
.cal-cell {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 15px; color: var(--ink);
}
.cal-cell.empty { visibility: hidden; }
.cal-cell.has-event { font-weight: 700; color: var(--sea-deep); }
.cal-cell.today { background: var(--sea); color: #fff; font-weight: 800; }
.cal-cell .dots { position: absolute; bottom: 5px; display: flex; gap: 3px; }
.cal-cell.today .dots { bottom: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.bd { background: var(--ochre); }
.dot.nd { background: var(--turquoise); }
.cal-cell.today .dot { background: #fff !important; }

.cal-list { display: flex; flex-direction: column; gap: 2px; }

/* Появление вида */
.view { animation: viewIn .28s cubic-bezier(.22,.61,.36,1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Аватар (общий) */
#avatar-slot img, #avatar-slot .avatar-fallback {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 3px solid var(--turquoise-soft);
}
#avatar-slot .avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--turquoise-soft); color: #fff; font-size: 26px; font-weight: 700;
}

/* Hero на главной */
.hero { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.hero .hi { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 700; color: var(--sea-deep); }
.hero .sub { font-size: 14px; color: #6a8a92; }

/* Карточка ближайших событий */
.upcoming {
  background: linear-gradient(135deg, var(--sea) 0%, var(--turquoise) 100%);
  color: #fff; border-radius: 20px; padding: 18px 18px 14px; margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(23,137,166,.28);
}
.upcoming.empty { background: #fff; color: var(--sea-deep); border: 1.5px solid #e6f1f2; box-shadow: var(--shadow-sm); }
.up-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; opacity: .85; font-weight: 700; margin-bottom: 10px; }
.up-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.18); }
.up-item:first-of-type { border-top: none; }
.up-when {
  flex: 0 0 auto; min-width: 56px; text-align: center; background: rgba(255,255,255,.2);
  border-radius: 10px; padding: 6px 4px; font-weight: 800; font-size: 13px; line-height: 1.1;
}
.up-when small { display: block; font-size: 10px; font-weight: 600; opacity: .9; }
.up-name { font-weight: 700; }
.up-kind { font-size: 12px; opacity: .85; }

/* Карточки навигации на главной */
.nav-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.nav-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: #fff; border: 1.5px solid #e6f1f2; border-radius: 18px; padding: 16px;
  cursor: pointer; box-shadow: var(--shadow-sm); font: inherit;
  transition: transform .14s ease, box-shadow .15s ease;
}
.nav-card:active { transform: scale(.98); }
.nc-icon { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.nc-cal { background: #e3f4f6; }
.nc-friends { background: #fdf0dc; }
.nc-profile { background: #e7f0ff; }
.nc-text { flex: 1; min-width: 0; }
.nc-text strong { display: block; color: var(--sea-deep); font-size: 16px; }
.nc-text span { font-size: 13px; color: #6a8a92; }
.nc-arrow { margin-left: auto; color: #b9d3d8; flex: 0 0 auto; }

/* Нижняя навигация */
.bottom-nav {
  flex: 0 0 auto; display: flex; background: #fff; border-top: 1px solid #e2eef0;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 20px rgba(11,79,108,.06);
}
.bn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; min-height: 54px; background: none; border: none; cursor: pointer;
  color: #7aa0a8; font: inherit; font-size: 11px; font-weight: 700;
  transition: transform .12s ease, color .15s ease;
}
.bn svg { width: 24px; height: 24px; }
.bn.active { color: var(--sea); }
.bn.active svg { transform: translateY(-1px) scale(1.06); }
.bn:active { transform: scale(.92); }

/* Стаггер-появление списков */
.stagger > * { animation: fadeUp .34s ease-out both; }
.stagger > *:nth-child(1){animation-delay:.03s}.stagger > *:nth-child(2){animation-delay:.06s}
.stagger > *:nth-child(3){animation-delay:.09s}.stagger > *:nth-child(4){animation-delay:.12s}
.stagger > *:nth-child(5){animation-delay:.15s}.stagger > *:nth-child(6){animation-delay:.18s}
.stagger > *:nth-child(7){animation-delay:.21s}.stagger > *:nth-child(8){animation-delay:.24s}
.stagger > *:nth-child(n+9){animation-delay:.27s}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .view, .stagger > *, .gull, .wave-move > * { animation: none !important; }
  .nav-card, .bn, .friend, .btn { transition: none !important; }
}

.error-msg {
  color: #b4321f;
  background: #fdecea;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ---------- Счётчик ---------- */
.counter {
  margin-top: 26px;
  text-align: center;
}
.counter .bar {
  height: 10px;
  background: rgba(255,255,255,.5);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}
.counter .bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--turquoise), var(--sand-deep));
  border-radius: 999px;
  transition: width .6s ease;
}
.counter .label { font-size: 14px; color: #eafafb; font-weight: 700; text-shadow: 0 1px 3px rgba(11,79,108,.4); }
.people {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-top: 12px;
}
.chip {
  background: rgba(255,255,255,.85);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--sea-deep);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------- Волны ---------- */
.waves {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  z-index: 1;
  line-height: 0;
  pointer-events: none;
}
.waves svg { width: 100%; height: 160px; display: block; }
.wave-move > * { animation: waveShift 12s linear infinite; }
.wave-move > *:nth-child(2) { animation-duration: 18s; animation-direction: reverse; }
@keyframes waveShift {
  from { transform: translateX(0); }
  to   { transform: translateX(-90px); }
}

/* ---------- Успех ---------- */
.success-overlay {
  position: fixed; inset: 0;
  background: rgba(11,79,108,.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 50;
}
.success-overlay.show { display: flex; }
.success-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 34px;
  text-align: center;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: pop .35s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.gull {
  font-size: 60px;
  display: inline-block;
  animation: flyAway 1.6s ease forwards;
}
@keyframes flyAway {
  0%   { transform: translate(0,0) rotate(0); opacity: 1; }
  60%  { transform: translate(60px,-40px) rotate(8deg); opacity: 1; }
  100% { transform: translate(160px,-120px) rotate(14deg); opacity: 0; }
}
.success-card h2 { color: var(--sea-deep); }
.success-card p { color: #35606e; margin: 6px 0 20px; }

.footer-note {
  text-align: center;
  margin-top: 26px;
  font-size: 12px;
  color: #eafafb;
  text-shadow: 0 1px 2px rgba(11,79,108,.4);
}
.footer-note a { color: #fff; }

.hidden { display: none !important; }

.spinner {
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  width: 22px; height: 22px;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
