/* ==========================================================================
   Бред сумасшедшего ☠️ — стили
   Палитра: мятный/тиффани + лиловый/светлофиолетовый
   ========================================================================== */

:root {
  --mint:        #17B8A6;
  --mint-light:  #6FE3D6;
  --mint-pale:   #E3FBF7;
  --lilac:       #8F6FE8;
  --lilac-light: #B79CFF;
  --lilac-pale:  #F1EBFF;

  --bg-1: #F3F1FE;
  --bg-2: #EAFBF8;

  --ink:      #241A3D;
  --ink-soft: #5B527A;
  --ink-faint:#9089AC;

  --card-bg: #FFFFFF;
  --card-radius: 22px;
  --control-radius: 14px;

  --shadow-soft: 0 10px 30px rgba(143,111,232,.16), 0 2px 10px rgba(23,184,166,.10);
  --shadow-lift: 0 18px 40px rgba(143,111,232,.24), 0 4px 14px rgba(23,184,166,.14);
  --shadow-press: 0 4px 12px rgba(143,111,232,.18);

  --danger: #E8618C;
  --danger-light: #FDE3EC;

  --font-display: "Unbounded", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--lilac); }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

::selection {
  background: var(--lilac-light);
  color: #fff;
}

/* Скроллбар */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--mint-light), var(--lilac-light));
  border-radius: 10px;
}
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------- */

.btn {
  border: none;
  border-radius: var(--control-radius);
  padding: 13px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.98); }

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--mint) 0%, var(--lilac) 100%);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { box-shadow: var(--shadow-lift); filter: brightness(1.04); }

.btn-block { width: 100%; }

.btn-ghost {
  background: rgba(143,111,232,.08);
  color: var(--ink-soft);
  box-shadow: none;
  border-radius: 12px;
  padding: 10px 14px;
}
.btn-ghost:hover { background: rgba(143,111,232,.16); }

.btn-danger {
  color: #fff;
  background: linear-gradient(120deg, var(--danger) 0%, #C24D74 100%);
  box-shadow: 0 10px 26px rgba(232,97,140,.35);
}

.btn-huinut { position: relative; overflow: hidden; }

/* --------------------------------------------------------------------
   Экран входа
   -------------------------------------------------------------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .55;
  animation: floaty 12s ease-in-out infinite;
}
.blob-1 { width: 340px; height: 340px; background: var(--mint-light); top: -80px; left: -80px; }
.blob-2 { width: 300px; height: 300px; background: var(--lilac-light); bottom: -100px; right: -60px; animation-delay: -4s; }
.blob-3 { width: 220px; height: 220px; background: var(--lilac); top: 40%; right: 20%; animation-delay: -8s; opacity: .35; }

@keyframes floaty {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -20px) scale(1.08); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border-radius: 28px;
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lift);
  text-align: center;
}

.login-logo {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  margin: 4px 0 4px;
  line-height: 1.25;
}

.login-subtitle {
  color: var(--ink-faint);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-form { text-align: left; display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 13px 15px;
  border-radius: var(--control-radius);
  border: 2px solid var(--lilac-pale);
  background: #FBFAFF;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  border-color: var(--lilac-light);
  box-shadow: 0 0 0 4px rgba(183,156,255,.22);
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  text-align: center;
}

/* --------------------------------------------------------------------
   Приложение — шапка
   -------------------------------------------------------------------- */

.app-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  padding: 16px 22px;
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 52px; height: 52px; flex-shrink: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  line-height: 1.2;
}
.brand-sub {
  font-size: 12px;
  color: var(--ink-faint);
}

.header-actions { display: flex; align-items: center; gap: 10px; }

/* --------------------------------------------------------------------
   Теги
   -------------------------------------------------------------------- */

.tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tag-chip {
  border: none;
  background: var(--lilac-pale);
  color: var(--lilac);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.tag-chip:hover { background: var(--lilac); color: #fff; transform: translateY(-1px); }
.tag-chip.is-active { background: linear-gradient(120deg, var(--mint), var(--lilac)); color: #fff; }
.tag-chip .tag-count { opacity: .7; font-weight: 500; margin-left: 3px; }

.active-filter {
  background: var(--mint-pale);
  color: var(--mint);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.chip-clear {
  border: none;
  background: rgba(23,184,166,.15);
  color: var(--mint);
  font-weight: 700;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}

/* --------------------------------------------------------------------
   Список заметок
   -------------------------------------------------------------------- */

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.note-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
  position: relative;
  transition: box-shadow .2s ease, transform .2s ease;
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--mint), var(--lilac)) 1;
}
.note-card:hover { box-shadow: var(--shadow-lift); }

.note-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.note-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  margin: 0;
  line-height: 1.35;
}

.note-date {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 3px;
}
.note-date .edited { font-style: italic; opacity: .8; }

.note-body {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 10px 0 14px;
}
.note-body a {
  color: var(--mint);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--mint-light);
}

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.note-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.note-actions .btn-ghost { font-size: 13px; padding: 8px 14px; }

.notes-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-faint);
}
.empty-emoji { font-size: 42px; margin-bottom: 10px; }

/* --------------------------------------------------------------------
   Комментарии
   -------------------------------------------------------------------- */

.comments-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--lilac-pale);
}

.comments-toggle {
  border: none;
  background: none;
  color: var(--lilac);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 0;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.comment-item {
  background: var(--bg-1);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13.5px;
}
.comment-item .comment-date {
  display: block;
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.comment-form input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--lilac-pale);
  background: #FBFAFF;
  outline: none;
}
.comment-form input:focus { border-color: var(--lilac-light); }
.comment-form button {
  border: none;
  background: var(--lilac-pale);
  color: var(--lilac);
  font-weight: 700;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 13px;
}
.comment-form button:hover { background: var(--lilac); color: #fff; }

/* --------------------------------------------------------------------
   Пагинация
   -------------------------------------------------------------------- */

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.page-btn {
  border: none;
  min-width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13.5px;
  box-shadow: var(--shadow-soft);
}
.page-btn.is-active {
  background: linear-gradient(120deg, var(--mint), var(--lilac));
  color: #fff;
}
.page-btn:disabled { opacity: .4; cursor: default; }

/* --------------------------------------------------------------------
   Модалки
   -------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36,26,61,.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--card-bg);
  border-radius: 26px;
  padding: 30px 26px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lift);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: pop-in .22s cubic-bezier(.2,.9,.3,1.3);
}

@keyframes pop-in {
  0% { transform: scale(.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: var(--lilac-pale);
  color: var(--lilac);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}

.composer-modal h2, .confirm-modal h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 18px;
  padding-right: 30px;
}

.composer-form { display: flex; flex-direction: column; gap: 14px; }

.field-hint {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0;
}

.existing-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.existing-tags .tag-chip { font-size: 11.5px; padding: 5px 11px; }

.confirm-modal { text-align: center; }
.confirm-emoji { font-size: 46px; margin-bottom: 6px; }
.confirm-text {
  color: var(--ink-faint);
  font-size: 13.5px;
  margin: 0 0 22px;
  word-break: break-word;
}
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* --------------------------------------------------------------------
   Конфетти
   -------------------------------------------------------------------- */

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}

/* --------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------- */

@media (max-width: 640px) {
  .app-shell { padding: 14px 12px 50px; }
  .app-header { padding: 14px 16px; border-radius: 20px; }
  .brand-logo { width: 42px; height: 42px; }
  .brand-text h1 { font-size: 14.5px; }
  .brand-sub { font-size: 11px; }
  .header-actions { width: 100%; justify-content: space-between; }
  #openComposerBtn { flex: 1; }
  #openComposerBtn span:last-child { font-size: 13px; }

  .note-card { padding: 18px 16px; border-radius: 18px; }
  .note-head { flex-direction: column; gap: 4px; }
  .note-date { padding-top: 0; }

  .modal { padding: 24px 18px; border-radius: 20px; }
  .login-card { padding: 32px 22px 26px; border-radius: 22px; }

  .comment-form { flex-direction: column; }
  .comment-form button { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-blob { animation: none; }
  .modal { animation: none; }
}
