/* ===== Основа ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
  --bg: #f3eeff;
  --card: #ffffff;
  --accent: #7c4dff;
  --accent2: #ff5da2;
  --ok: #2ec27e;
  --text: #2b2140;
  --muted: #6f6191;
  --shadow: 0 4px 14px rgba(90, 60, 160, .12);
  --radius: 18px;
}

html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Радужный «калейдоскоп»: лёгкая белая вуаль сверху, чтобы текст не терялся */
  background:
    linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, .22)),
    repeating-radial-gradient(circle at 50% 30%,
      #ff3db1 0px, #ff8a00 70px, #ffe93d 140px, #3ee06b 210px,
      #2fb1ff 280px, #b44dff 350px, #ff3db1 420px);
  background-attachment: fixed;
  color: var(--text);
  overscroll-behavior-y: none;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
/* Заголовки секций — на белой плашке, иначе потеряются на радуге */
h2 {
  display: inline-block; font-size: 15px; color: #5b4a86; margin: 18px 4px 8px;
  font-weight: 700; background: rgba(255, 255, 255, .85); padding: 5px 14px;
  border-radius: 999px; box-shadow: var(--shadow);
}

.screen { min-height: 100dvh; }

/* ===== Вход ===== */
#screen-login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box {
  width: 100%; max-width: 380px; text-align: center;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(6px);
  border-radius: 28px; padding: 26px 18px; box-shadow: 0 8px 30px rgba(60, 30, 120, .25);
}
.login-logo { font-size: 64px; animation: bounce 2.2s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-10px);} }
.login-box h1 { font-size: 32px; margin-top: 6px; }
.login-sub { color: var(--muted); margin: 6px 0 20px; }

.user-cards { display: flex; gap: 14px; justify-content: center; }
.user-card {
  flex: 1; max-width: 160px; background: var(--card); border-radius: var(--radius);
  padding: 22px 10px; box-shadow: var(--shadow); transition: transform .12s;
}
.user-card:active { transform: scale(.95); }
.user-card .uc-emoji { font-size: 44px; display: block; }
.user-card .uc-name { font-size: 18px; font-weight: 700; margin-top: 8px; display: block; }
.user-card .uc-role { font-size: 12px; color: var(--muted); }

.pin-title { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; min-height: 18px; margin-bottom: 8px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: #d9d0f0; }
.pin-dot.on { background: var(--accent); }
.pin-error { color: #e0245e; min-height: 20px; font-size: 14px; margin: 4px 0; }

.keypad {
  display: grid; grid-template-columns: repeat(3, 72px); gap: 12px;
  justify-content: center; margin-top: 8px;
}
.key {
  height: 64px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  font-size: 24px; font-weight: 600; transition: transform .08s;
}
.key:active { transform: scale(.92); }
.key-ok { background: var(--ok); color: #fff; }
.key-back { color: var(--muted); }

.link-btn { color: var(--muted); font-size: 14px; margin-top: 16px; text-decoration: underline; }

/* ===== Основной экран ===== */
#screen-main { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(90, 60, 160, .10);
}
.hdr-user { font-weight: 700; font-size: 18px; }
.hdr-stars {
  background: #fff3c4; color: #8a6d00; font-weight: 700; padding: 4px 12px;
  border-radius: 999px; font-size: 14px;
}
.topbar .link-btn { margin: 0 0 0 auto; }

#content { flex: 1; overflow-y: auto; padding: 0 14px 90px; }

/* ===== Задания ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.task-card.done { opacity: .55; }
.tc-emoji { font-size: 30px; }
.tc-mid { flex: 1; min-width: 0; }
.tc-title { font-weight: 600; overflow-wrap: anywhere; }
.tc-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tc-stars { font-size: 13px; color: #b8860b; font-weight: 700; white-space: nowrap; }
.btn-done {
  background: var(--ok); color: #fff; font-weight: 700; border-radius: 14px;
  padding: 10px 14px; font-size: 15px; transition: transform .08s; white-space: nowrap;
}
.btn-done:active { transform: scale(.93); }
.tc-status { font-size: 20px; }
.btn-del { color: #c9bfe0; font-size: 18px; padding: 6px; }
.empty {
  color: #5b4a86; text-align: center; padding: 14px; font-size: 14px;
  background: rgba(255, 255, 255, .8); border-radius: var(--radius);
}

/* ===== Чат ===== */
#tab-chat { display: flex; flex-direction: column; }
.chat-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 2px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 18px; line-height: 1.35;
  overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.them { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.msg-time { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; text-align: right; }

.chat-form {
  position: fixed; left: 0; right: 0; bottom: 64px; display: flex; gap: 8px;
  padding: 8px 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
}
.chat-form input {
  flex: 1; min-width: 0; border: 2px solid #e5dcf7; border-radius: 999px;
  padding: 11px 16px; font: inherit; outline: none; background: #fff;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-send {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.chat-emoji-btn {
  width: 46px; height: 46px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow); font-size: 22px; flex-shrink: 0; transition: transform .08s;
}
.chat-emoji-btn:active { transform: scale(.9); }

.emoji-panel {
  position: fixed; left: 0; right: 0; bottom: 126px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 2px; padding: 10px 12px; max-height: 200px; overflow-y: auto;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  box-shadow: 0 -2px 12px rgba(90,60,160,.12); z-index: 4;
}
.emoji-panel button {
  font-size: 26px; padding: 6px 0; border-radius: 10px; transition: transform .08s;
}
.emoji-panel button:active { transform: scale(1.25); background: #f4f0fd; }

@media (min-width: 700px) {
  .emoji-panel { max-width: 640px; margin: 0 auto; }
}

/* ===== Звёзды ===== */
.stars-hero {
  text-align: center; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 16px; margin-top: 14px;
}
.stars-big { font-size: 44px; font-weight: 800; }
.stars-money { font-size: 18px; font-weight: 700; color: #b8860b; margin-top: 2px; }
.streak-line { color: var(--muted); margin-top: 6px; font-size: 15px; }

.btn-money {
  margin-top: 14px; background: linear-gradient(135deg, #ffb300, #ff7a00); color: #fff;
  font-weight: 800; font-size: 16px; padding: 12px 22px; border-radius: 16px;
  box-shadow: 0 4px 14px rgba(255, 150, 0, .45); transition: transform .1s;
}
.btn-money:active { transform: scale(.94); }

.pending-box {
  margin-top: 14px; background: #fff3c4; border-radius: 14px; padding: 12px 14px;
  font-weight: 600; color: #8a6d00; display: flex; flex-direction: column;
  gap: 2px; align-items: center;
}
.pending-box .link-btn { margin-top: 4px; }

.req-row {
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  margin-top: 14px; background: #f4f0fd; border-radius: 14px; padding: 14px; font-weight: 600;
}
.req-actions { display: flex; gap: 10px; }
.btn-approve { background: var(--ok); color: #fff; font-weight: 700; border-radius: 12px; padding: 10px 16px; }
.btn-reject { background: #ffe3ec; color: #e0245e; font-weight: 700; border-radius: 12px; padding: 10px 16px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat-tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 8px; text-align: center; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 11.5px; color: var(--muted); font-weight: 600; line-height: 1.25; }

.ex-balance { color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.ex-hint { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
#tf-stars-custom, #ex-amount { margin-top: 8px; }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.hist-row {
  display: flex; justify-content: space-between; gap: 10px; background: var(--card);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px;
}
.hist-title { overflow-wrap: anywhere; }
.hist-right { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.hist-stars { color: #b8860b; font-weight: 700; margin-right: 6px; }

/* ===== Заметки ===== */
.notes-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; align-items: start;
}
.note-card {
  border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .1s; min-height: 90px;
  display: flex; flex-direction: column; gap: 8px; text-align: left;
}
.note-card:active { transform: scale(.97); }
.note-text {
  flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px;
  line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 7;
  -webkit-box-orient: vertical; overflow: hidden;
}
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.note-check { font-size: 19px; line-height: 1; padding: 2px; transition: transform .1s; }
.note-check:active { transform: scale(1.3); }
.note-card.done .note-text { text-decoration: line-through; opacity: .5; }
.note-date { font-size: 11px; color: rgba(43, 33, 64, .55); }
/* пастельные «стикеры» */
.note-c0 { background: #fff9c4; }
.note-c1 { background: #ffe0ef; }
.note-c2 { background: #e0f4ff; }
.note-c3 { background: #e6ffe0; }
.note-c4 { background: #f3e5ff; }
.note-c5 { background: #ffeeda; }

#nf-text {
  width: 100%; border: 2px solid #e5dcf7; border-radius: 12px; padding: 11px 12px;
  font: inherit; color: var(--text); outline: none; background: #fff;
  resize: vertical; min-height: 140px; margin-bottom: 10px;
}
#nf-text:focus { border-color: var(--accent); }
.btn-danger { color: #e0245e; font-weight: 600; padding: 11px 12px; margin-right: auto; }

/* ===== Нижняя навигация ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  box-shadow: 0 -2px 12px rgba(90,60,160,.10);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px; font-size: 20px; color: var(--muted); position: relative;
}
.tabbtn span { font-size: 11px; font-weight: 600; }
.tabbtn.active { color: var(--accent); }
.badge {
  position: absolute; top: 4px; right: calc(50% - 26px); background: var(--accent2);
  color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px; font-style: normal;
}

/* ===== FAB ===== */
.fab {
  position: fixed; right: 18px; bottom: 84px; width: 58px; height: 58px;
  border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 30px; box-shadow: 0 6px 18px rgba(124,77,255,.45);
  transition: transform .1s; z-index: 5;
}
.fab:active { transform: scale(.9); }

/* ===== Диалог ===== */
dialog {
  border: none; border-radius: 22px; padding: 20px; width: min(92vw, 420px);
  box-shadow: 0 10px 40px rgba(40,20,90,.25); margin: auto;
}
dialog::backdrop { background: rgba(43,33,64,.45); }
dialog h2 { color: var(--text); font-size: 20px; margin: 0 0 14px; }
.fld { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); font-weight: 600; }
.fld > span { display: block; margin-bottom: 6px; }
.fld input {
  width: 100%; margin-top: 6px; border: 2px solid #e5dcf7; border-radius: 12px;
  padding: 11px 12px; font: inherit; color: var(--text); outline: none; background: #fff;
}
.fld input:focus { border-color: var(--accent); }

.emoji-row, .chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-btn {
  font-size: 22px; width: 42px; height: 42px; border-radius: 12px; background: #f4f0fd;
  border: 2px solid transparent;
}
.emoji-btn.sel { border-color: var(--accent); background: #ece3ff; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: #f4f0fd; font-size: 14px;
  font-weight: 600; color: var(--text); border: 2px solid transparent;
}
.chip.sel { border-color: var(--accent); background: #ece3ff; color: var(--accent); }

.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-main {
  background: var(--accent); color: #fff; font-weight: 700; padding: 11px 20px;
  border-radius: 14px;
}
.btn-plain { color: var(--muted); padding: 11px 12px; }

/* ===== Празднование ===== */
.celebrate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(43,33,64,.35); z-index: 50;
}
.celebrate-inner {
  background: #fff; border-radius: 24px; padding: 30px 36px; text-align: center;
  font-size: 22px; font-weight: 800; box-shadow: 0 10px 40px rgba(40,20,90,.3);
  animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
  white-space: pre-line;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (min-width: 700px) {
  #content, .topbar { max-width: 640px; margin-left: auto; margin-right: auto; width: 100%; }
  .chat-form { max-width: 640px; margin: 0 auto; }
}
