/* ============================================================
   Айса — стили приложения (дизайн-язык на tokens.css).
   Селекторы совпадают с разметкой app.js/diary.js — логику не трогаем.
   ============================================================ */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Каркас ---------- */
.app-shell { display: flex; flex: 1 1 auto; min-height: 0; }

.sidebar {
  flex: 0 0 248px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px; overflow-y: auto;
}
.brand { font-family: var(--font-serif); font-weight: 600; font-size: 23px; letter-spacing: -.2px; padding: 4px 12px 2px; }
.brand-sub { font-family: var(--font-sans); font-weight: 400; font-size: 11px; color: var(--muted); margin-top: 2px; padding-bottom: 16px; }

.nav-items { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  font: inherit; text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: transparent; color: var(--ink-2);
  border: 0; border-radius: 12px; padding: 11px 12px;
  font-weight: 500; cursor: pointer;
}
.nav-item .nav-ic { width: 22px; height: 22px; flex: 0 0 auto; }
.nav-item span { flex: 1 1 auto; }
.nav-item.nav-plain { justify-content: center; }
.nav-item:hover:not(:disabled) { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item.active .nav-ic { color: var(--accent-text); }
.nav-item:disabled { color: var(--muted); opacity: .5; cursor: not-allowed; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12.5px; position: relative; }

/* Профиль-кнопка (как аккаунт-меню в Claude) */
.acct-btn { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent;
  cursor: pointer; border-radius: 12px; padding: 8px 10px; }
.acct-btn:hover { background: var(--bg); }
.acct-av { width: 30px; height: 30px; border-radius: 50%; background: var(--grad-avatar); color: #fff;
  display: grid; place-items: center; font-family: var(--font-serif); font-weight: 600; font-size: 14px; flex: 0 0 auto; }
.acct-name { flex: 1 1 auto; text-align: left; font-weight: 600; font-size: 14px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn .chev { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }

.acct-menu { position: absolute; bottom: calc(100% + 6px); left: 8px; right: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 16px 44px -12px rgba(24,24,20,.28); padding: 6px; z-index: 60; }
.acct-menu.hidden { display: none; }
.acct-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.acct-head .n { font-weight: 600; font-size: 14px; color: var(--ink); }
.acct-head .e { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.menu-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: transparent;
  text-align: left; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu-item:hover { background: var(--bg); }
.menu-item .nav-ic { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .nav-ic { color: var(--danger); }
.menu-div { height: 1px; background: var(--line); margin: 6px 8px; }

.main-area { flex: 1 1 auto; min-width: 0; display: flex; }
.main-area > .view { flex: 1 1 auto; }
.view { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view.hidden { display: none !important; }

/* ---------- Шапка вида ---------- */
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.chat-header .title { font-family: var(--font-serif); font-weight: 500; font-size: 18px; }

/* ---------- Кнопки ---------- */
.btn {
  font: inherit; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-btn); padding: 12px 18px; cursor: pointer;
  box-shadow: var(--shadow);
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { color: var(--muted); opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-primary { color: #fff; background: var(--grad-accent); border: 0; box-shadow: var(--shadow-btn); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.03); background: var(--grad-accent); }
.btn-small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Сообщения (чат) ---------- */
.messages {
  flex: 1 1 auto; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 16px;
  max-width: 760px; width: 100%; margin: 0 auto;
}
.msg {
  padding: 12px 15px; border-radius: 18px; max-width: 74%;
  white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.5;
}
.msg .role { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 5px; }
/* Пользователь — справа, мятный пузырь */
.msg.user { align-self: flex-end; background: var(--mint-100); border: 1px solid var(--mint-200); border-top-right-radius: 6px; }
.msg.user .role { display: none; }
/* Айса — слева, белый пузырь */
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 6px; box-shadow: var(--shadow); }
/* Кризис-ответ — мягкий тревожный акцент */
.msg.crisis { align-self: flex-start; background: var(--danger-bg-2); border: 1px solid var(--danger-line); border-top-left-radius: 6px; }
.msg.crisis .role { color: var(--danger); }
.msg.pending { opacity: .6; border-style: dashed; }

/* ---------- Сессия: UI по макетам (изолировано от дневника) ---------- */
.session-header { justify-content: center; gap: 12px; padding: 12px 20px; }
.session-back, .session-head-spacer { width: 36px; height: 36px; flex: 0 0 36px; }
.session-back { display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font: 28px/1 var(--font-sans); cursor: pointer; }
.session-back:hover { background: var(--bg); }
.session-heading { flex: 1 1 auto; min-width: 0; text-align: center; }
.session-heading .title { display: block; font-family: var(--font-serif); font-size: 18px; font-weight: 500; }
.session-status { display: inline-block; margin-top: 2px; color: var(--mint-700); font-size: 12.5px; font-weight: 600; }
#view-session .session-thread { max-width: 760px; padding: 20px 24px; gap: 18px; }
.session-msg { display: flex; align-items: flex-start; gap: 9px; }
.session-msg-user { justify-content: flex-end; }
.session-avatar { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--grad-avatar); font-family: var(--font-serif); font-size: 14px; font-weight: 600; }
.session-bubble { max-width: min(74%, 560px); padding: 12px 15px; border: 1px solid var(--line); border-radius: 18px; border-top-left-radius: 6px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.session-msg-user .session-bubble { border-color: var(--mint-200); border-top-left-radius: 18px; border-top-right-radius: 6px; background: var(--mint-100); box-shadow: none; }
.session-msg-crisis .session-bubble { border-color: var(--danger-line); background: var(--danger-bg-2); }
.session-role { margin-bottom: 5px; color: var(--danger); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.session-msg-pending { opacity: .65; }
.session-typing { max-width: 760px; padding: 0 24px 10px; }
.session-end { max-width: 760px; width: 100%; margin: 0 auto; padding: 0 24px 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.session-end-separator { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.session-end-separator::before, .session-end-separator::after { height: 1px; flex: 1; background: var(--line-2); content: ''; }
.session-end-homework { margin: 16px 0 12px; padding: 16px; border: 1px solid var(--mint-200); border-radius: 16px; background: var(--mint-50); color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.session-end-homework .label { margin-bottom: 4px; color: var(--mint-700); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.session-end .btn { width: 100%; border-radius: 16px; padding: 14px 18px; }
#view-session .session-composer-row { max-width: 760px; width: 100%; padding: 8px 24px 4px; }
.session-composer { display: flex; align-items: flex-end; width: 100%; gap: 10px; padding: 8px 8px 8px 16px; border: 1px solid var(--line-2); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
#view-session .session-composer .input { min-width: 0; height: auto; min-height: 30px; max-height: 160px; padding: 5px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow-y: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
#view-session .session-composer .btn { width: 36px; height: 36px; min-width: 36px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
#view-session .session-composer .btn svg { width: 18px; height: 18px; }

.typing { padding: 4px 24px 10px; font-size: 13px; color: var(--muted); max-width: 760px; width: 100%; margin: 0 auto; }

/* ---------- Панель закрытия сессии ---------- */
.session-end {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  margin: 0 24px 12px; padding: 18px; box-shadow: var(--shadow);
  max-width: 712px; width: calc(100% - 48px); align-self: center;
}
.session-end h3 { font-family: var(--font-serif); font-weight: 500; margin: 0 0 10px; font-size: 18px; }
.session-end .block { margin-bottom: 12px; }
.session-end .label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }

/* ---------- Ввод ---------- */
.input-row {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 24px; flex: 0 0 auto;
  max-width: 760px; width: 100%; margin: 0 auto;
}
.input {
  flex: 1 1 auto; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 22px; padding: 12px 16px; resize: none; height: 46px; min-height: 46px; outline: none;
  box-shadow: var(--shadow);
}
.input:focus { border-color: var(--accent); }
.input-row .btn { border-radius: 22px; height: 46px; padding-top: 0; padding-bottom: 0; display: inline-flex; align-items: center; }
#send-btn, #diary-send { color: #fff; background: var(--grad-accent); border: 0; box-shadow: var(--shadow-btn); }
#send-btn:hover:not(:disabled), #diary-send:hover:not(:disabled) { filter: brightness(1.03); }
#send-btn:disabled, #diary-send:disabled { background: var(--line-2); color: var(--muted); box-shadow: none; }

/* ---------- Дисклеймер ---------- */
.disclaimer { text-align: center; padding: 6px 24px 14px; font-size: 11px; color: var(--muted); }

/* ---------- Главная (дашборд) ---------- */
.home-body { padding: 32px 24px; overflow-y: auto; max-width: 860px; width: 100%; margin: 0 auto; }

/* ---------- Профиль ---------- */
.profile-body { flex: 1 1 auto; overflow-y: auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px; }
.profile-card, .profile-list { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.profile-me { display: flex; align-items: center; gap: 14px; padding: 16px; }
.profile-avatar { width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--grad-avatar); color: #fff; font-family: var(--font-serif); font-size: 24px; font-weight: 600; }
.profile-info { min-width: 0; }
.profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.profile-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; color: var(--muted); font-size: 13px; }
.profile-subscription { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 16px; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.profile-subscription:hover { border-color: var(--mint-300); }
.profile-sub-icon, .profile-row-icon { display: grid; place-items: center; color: var(--mint-600); background: var(--mint-50); }
.profile-sub-icon { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px; }
.profile-sub-icon .nav-ic { width: 20px; height: 20px; }
.profile-sub-copy { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; }
.profile-sub-copy b { font-size: 14.5px; }
.profile-sub-copy small { margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.profile-manage { flex: 0 0 auto; color: var(--mint-700); font-size: 13px; font-weight: 600; }
.profile-group-label { margin: 24px 4px 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.profile-list { overflow: hidden; }
.profile-row { display: flex; align-items: center; width: 100%; min-height: 63px; gap: 14px; padding: 15px 16px; border: 0; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.profile-row + .profile-row { border-top: 1px solid var(--line); }
.profile-row:hover:not(:disabled) { background: var(--bg); }
.profile-row-icon { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; }
.profile-row-icon .nav-ic { width: 19px; height: 19px; }
.profile-row-label { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 500; }
.profile-row-value, .profile-row-soon { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.profile-row-soon { font-size: 12px; }
.profile-chevron { width: 8px; height: 14px; flex: 0 0 auto; color: var(--line-2); }
.profile-row:disabled { cursor: not-allowed; }
.profile-row:disabled .profile-row-icon { color: var(--muted); background: var(--bg); }
.profile-row.danger { color: var(--danger); }
.profile-row.danger .profile-row-icon { color: var(--danger); background: var(--danger-bg); }

/* ---------- Уведомления ---------- */
.notification-header { justify-content: center; gap: 12px; }
.notification-header .title { flex: 1 1 auto; text-align: center; }
.notifications-body { flex: 1 1 auto; overflow-y: auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 24px 32px; }
.notification-access { margin-bottom: 22px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); }
.notification-access b { display: block; font-size: 15px; }
.notification-access p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.notification-access .btn { width: 100%; margin-top: 14px; border-radius: 14px; }
.notification-access-on { border-color: var(--mint-200); background: var(--mint-50); }
.notification-group-label { margin: 20px 4px 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.notification-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); }
.notification-row { display: flex; align-items: center; width: 100%; gap: 14px; padding: 15px 16px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.notification-row + .notification-row { border-top: 1px solid var(--line); }
.notification-row:hover:not(:disabled) { background: var(--bg); }
.notification-row:disabled { cursor: not-allowed; }
.notification-copy { flex: 1 1 auto; }
.notification-copy > span { display: block; font-size: 15px; font-weight: 500; }
.notification-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.notification-switch { position: relative; width: 46px; height: 28px; flex: 0 0 auto; border-radius: var(--r-pill); background: var(--line-2); transition: background .2s; }
.notification-switch::after { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22); content: ''; transition: left .2s; }
.notification-switch.on { background: var(--mint-400); }
.notification-switch.on::after { left: 21px; }
.notification-row:disabled .notification-switch { opacity: .55; }
.notification-test-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.notification-test { margin: 0; }
.notification-test-tools p { width: 100%; margin: 0; text-align: center; font-size: 13px; }

@media (max-width: 640px) {
  .profile-body { padding: 16px; }
  .profile-row-value { max-width: 38%; }
  .notifications-body { padding: 16px; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-family: var(--font-serif); font-weight: 500; margin: 0 0 4px; font-size: 18px; }
.card .card-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.45; }
.card-row { display: flex; gap: 10px; flex-wrap: wrap; }

.home-date { font-size: 13px; color: var(--muted); text-transform: lowercase; letter-spacing: .2px; }
.home-greeting { font-family: var(--font-serif); font-weight: 500; font-size: 28px; line-height: 1.18; letter-spacing: -.2px; margin: 6px 0 0; }
.hero { margin-top: 18px; }
.hero-q { font-family: var(--font-serif); font-size: 22px; line-height: 1.28; letter-spacing: -.2px; }
.hero .btn-primary { margin-top: 18px; width: 100%; }
.home-sec { margin: 24px 4px 12px; }

.home-cards { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.home-cards > * { min-width: 0; }
.home-mini { display: flex; flex-direction: column; min-height: 150px; cursor: pointer; }
.home-mini:hover { border-color: var(--accent-border); }
.mini-top { display: flex; align-items: center; justify-content: space-between; min-height: 34px; margin-bottom: 12px; }
.home-mini h3 { margin: 0; font-size: 17px; }
.home-mini p { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; line-height: 1.35; }
.home-spacer { flex: 1; }
.home-foot { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--accent-text); display: inline-flex; align-items: center; gap: 5px; }
.streak-pill { font-size: 14px; font-weight: 600; color: var(--mint-700); background: var(--mint-50);
  border: 1px solid var(--mint-200); border-radius: 999px; padding: 3px 11px; white-space: nowrap; }
.streak-pill small { font-size: 1em; color: var(--muted); font-weight: 500; }

.icon-tile { width: 34px; height: 34px; border-radius: 10px; background: var(--mint-50); color: var(--mint-600); display: grid; place-items: center; }
.icon-tile .nav-ic { width: 18px; height: 18px; }

.home-diary { grid-column: 1 / -1; }
.home-bar { margin-top: 10px; height: 6px; background: var(--mint-50); border-radius: 999px; overflow: hidden; }
.home-bar > i { display: block; height: 100%; background: var(--grad-accent); border-radius: 999px; }

@media (min-width: 900px) {
  .home-cards { grid-template-columns: repeat(3, 1fr); }
  .home-diary { grid-column: auto; }
}

/* ---------- История сессий ---------- */
.history-list { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; max-width: 720px; width: 100%; margin: 0 auto; }
.sess-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; cursor: pointer; box-shadow: var(--shadow); }
.sess-card:hover { border-color: var(--accent-border); }
.sess-top { display: flex; align-items: flex-start; gap: 12px; }
.sess-ttl { min-width: 0; flex: 1; }
.sess-ttl h3 { font-family: var(--font-serif); font-weight: 500; font-size: 16px; margin: 0; line-height: 1.25; }
.sess-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.sess-card .sm { font-size: 13px; color: var(--ink-2); margin-top: 10px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sess-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.status { font-size: 11.5px; font-weight: 600; border-radius: var(--r-pill); padding: 4px 10px; }
.status.active { color: var(--mint-700); background: var(--mint-50); border: 1px solid var(--mint-200); }
.status.done { color: var(--ink-2); background: var(--bg); border: 1px solid var(--line-2); }
.sess-action { font-size: 13px; font-weight: 600; color: var(--accent-text); display: inline-flex; align-items: center; gap: 5px; }
.empty-state { color: var(--muted); font-size: 14px; padding: 8px 4px; }

/* ---------- Портрет ---------- */
.portrait-body { max-width: 760px; width: 100%; margin: 0 auto; padding: 28px 24px 36px; overflow-y: auto; }
.portrait-loading { padding-top: 8px; }
.portrait-hero { text-align: center; padding: 4px 8px 6px; }
.portrait-icon { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; color: #fff; background: var(--grad-accent); box-shadow: 0 8px 22px rgba(76,180,151,.35); }
.portrait-icon .nav-ic { width: 26px; height: 26px; }
.portrait-hero h1, .portrait-card h2 { font-family: var(--font-serif); font-weight: 500; }
.portrait-hero h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.2px; }
.portrait-hero p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.portrait-card { margin-top: 18px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.portrait-card h2 { margin: 0 0 12px; font-size: 17px; }
.portrait-text { color: var(--ink-2); font-size: 14.5px; line-height: 1.65; }
.portrait-text p { margin: 0; white-space: pre-wrap; }
.portrait-text p + p { margin-top: 14px; }
.portrait-locked > p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.portrait-progress { height: 7px; margin-top: 20px; overflow: hidden; border-radius: 999px; background: var(--mint-100); }
.portrait-progress i { display: block; height: 100%; border-radius: inherit; background: var(--grad-accent); }
.portrait-progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.portrait-next { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 12.5px; }
.portrait-next b { color: var(--accent-text); font-weight: 600; }

/* ---------- Подписка ---------- */
.subscription-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subscription-top > p { margin: 0; font-size: 18px; }
.subscription-top + p { margin: 10px 0 0; font-size: 14px; }
.subscription-note { margin: 16px 4px 0; color: var(--muted); text-align: center; font-size: 12.5px; line-height: 1.5; }
.subscription-cta { width: 100%; margin-top: 20px; }
.plan-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan-choice { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 156px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.plan-choice:hover:not(:disabled) { border-color: var(--mint-400); background: var(--mint-50); }
.plan-choice.selected { border: 2px solid var(--mint-400); background: var(--mint-50); box-shadow: 0 10px 24px -16px rgba(32, 122, 100, .55); }
.plan-choice:disabled { background: var(--bg); color: var(--muted); cursor: default; opacity: 1; }
.plan-card-name { font-size: 18px; font-weight: 600; line-height: 1.2; }
.plan-card-price { margin-top: auto; color: var(--ink); font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: -.3px; }
.plan-card-price small { color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0; }
.plan-card-meta { display: flex; align-items: center; gap: 6px; min-height: 24px; margin-top: 9px; }
.plan-card-meta b { color: var(--mint-700); font-size: 12px; font-weight: 700; }
.plan-card-meta em { padding: 3px 8px; border-radius: var(--r-pill); background: var(--mint-100); color: var(--mint-700); font-size: 12px; font-style: normal; font-weight: 700; }
.plan-choice:disabled .plan-card-price { color: var(--muted); font-weight: 500; }
@media (max-width: 380px) {
  .plan-selector { gap: 8px; }
  .plan-choice { min-height: 140px; padding: 14px; }
  .plan-card-name { font-size: 16px; }
  .plan-card-price { font-size: 20px; }
  .plan-card-price small { display: block; margin-top: 2px; font-size: 11px; }
}
.subscription-add-payment { color: var(--mint-700); }
.payment-row-remove { display: grid; place-items: center; width: 32px; height: 32px; margin-left: auto; padding: 0; border: 0; border-radius: 9px; background: var(--danger-bg); color: var(--danger); cursor: pointer; }
.payment-row-remove .nav-ic { width: 18px; height: 18px; }
.payment-set-default { margin-left: auto; border: 0; background: transparent; color: var(--mint-700); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.payment-method-row .profile-row-value { margin-left: auto; }
.payment-method-row .payment-row-remove { margin-left: 12px; }
.subscription-row-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.subscription-cancel { padding-top: 18px; text-align: center; }
.subscription-cancel h1 { margin: 0; font-family: var(--font-serif); font-weight: 500; font-size: 24px; line-height: 1.25; }
.subscription-cancel > p { margin: 10px 0 0; color: var(--ink-2); font-size: 14px; }
.subscription-losses { margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.subscription-loss { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--ink-2); font-size: 14px; line-height: 1.35; }
.subscription-loss + .subscription-loss { border-top: 1px solid var(--line); }
.subscription-loss > span:first-child { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; color: var(--danger); background: var(--danger-bg); }
.subscription-loss .nav-ic { width: 12px; height: 12px; }
.subscription-danger-button { width: 100%; margin-top: 6px; padding: 14px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.subscription-offer { display: flex; flex-direction: column; min-height: min(620px, calc(100vh - 180px)); padding: 24px 8px 0; }
.subscription-offer-copy { text-align: center; }
.subscription-offer-copy h1 { margin: 0; font-family: var(--font-serif); font-size: 27px; font-weight: 500; line-height: 1.2; }
.subscription-offer-copy p { margin: 12px 0 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.subscription-offer-price { margin-top: 24px; padding: 22px; border: 1.5px solid var(--mint-500); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.subscription-offer-price strong { display: block; font-size: 34px; letter-spacing: -.5px; }
.subscription-offer-price strong small { color: var(--muted); font-size: 16px; font-weight: 500; }
.subscription-offer-price span { display: flex; justify-content: center; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 14px; }
.subscription-offer-price b { color: var(--mint-700); }
.subscription-offer-spacer { flex: 1; }

/* ---------- Дневник ---------- */
.streak { font-size: 13px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--r-pill); padding: 5px 11px; }
.diary-head-right { display: flex; align-items: center; gap: 8px; }

/* Дневник: единая центрированная колонка (как чат) — всё выравнивается по ней */
.diary-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.diary-foot { flex: 0 0 auto; padding: 8px 0 4px; }
.diary-col { max-width: 760px; width: 100%; margin: 0 auto; padding: 0 24px; }
#view-diary .messages { max-width: none; margin: 0; padding: 16px 0 8px; flex: none; overflow: visible; }
#view-diary .input-row { max-width: none; margin: 0; padding: 0; align-items: flex-end; }
#diary-input { max-height: 160px; overflow-y: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }

.weekly-card, .calendar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin: 16px 0 0; padding: 16px; box-shadow: var(--shadow); }
.weekly-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.weekly-head b { font-family: var(--font-serif); font-weight: 500; }
.weekly-body { font-size: 14px; white-space: pre-wrap; color: var(--ink-2); }
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-title { font-weight: 600; flex: 1 1 auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-day { font: inherit; font-size: 13px; text-align: center; padding: 8px 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.cal-day.empty { border-color: transparent; cursor: default; }
.cal-day.future { color: #c4c4bd; border-color: var(--line); cursor: default; }
.cal-day.has { border-color: var(--accent); font-weight: 700; color: var(--accent-text); }
.cal-day.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.diary-day-label { padding: 14px 0 0; font-size: 13px; font-weight: 600; }
.diary-empty { padding: 8px 0; }
.dl-count { color: var(--muted); font-weight: 500; }
.diary-limit { padding: 6px 0 0; font-size: 12px; color: var(--muted); }
.entry-mood { font-size: 11px; color: var(--muted); }

/* ---------- Модалки (как листы) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22,22,18,.42); backdrop-filter: blur(2px); z-index: 40; }
.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(440px, 92vw); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 24px; box-shadow: 0 30px 70px -20px rgba(24,24,20,.4);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal-head b { font-family: var(--font-serif); font-weight: 500; font-size: 20px; }
.modal-body { padding: 8px 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-body .muted { font-size: 13.5px; line-height: 1.5; }
.modal-x { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.paywall-list { margin: 4px 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }

/* ---------- Пейвол ---------- */
#paywall-modal .modal-head { justify-content: flex-end; padding: 14px 16px 0; }
.paywall-body { text-align: center; }
.paywall-badge { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto; display: grid; place-items: center;
  background: var(--grad-avatar); box-shadow: 0 8px 22px rgba(76,180,151,.35); }
.paywall-title { font-family: var(--font-serif); font-weight: 500; font-size: 22px; line-height: 1.22; margin: 0; }
.paywall-sub { font-size: 13.5px; line-height: 1.5; color: var(--muted); margin: 0; }
.paywall-features { text-align: left; background: var(--bg); border-radius: 16px; padding: 4px 14px; }
.pf { display: flex; align-items: center; gap: 11px; padding: 11px 0; font-size: 14px; color: var(--ink); line-height: 1.35; }
.pf + .pf { border-top: 1px solid var(--line); }
.pf .ck { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; background: var(--mint-100); color: var(--mint-600); display: grid; place-items: center; }
.pf b { font-weight: 600; }
.paywall-plans { display: flex; flex-direction: column; gap: 8px; }
.plan-opt { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 13px 15px; cursor: pointer; }
.plan-opt.sel { border-color: var(--mint-500); background: var(--mint-50); }
.plan-opt .pname { flex: 1; text-align: left; font-size: 15px; font-weight: 600; }
.plan-opt .tag { font-size: 11px; font-weight: 600; color: var(--mint-700); background: var(--mint-100); border-radius: 999px; padding: 3px 8px; }
.plan-opt .price { font-size: 15px; font-weight: 600; }
.plan-opt .price small { color: var(--muted); font-weight: 500; font-size: 12px; }
.modal .input { border-radius: var(--r-sm); height: auto; min-height: 0; padding: 14px 16px; }
select.input {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238c8c84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6 -6'/></svg>");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px;
}

/* ---------- Интейк: макет знакомства внутри общего модального контейнера ---------- */
#intake-modal { width: min(500px, 92vw); }
#intake-modal .intake-head { padding-bottom: 0; }
.intake-body { gap: 0; padding-top: 8px; }
.intake-sub { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.intake-field { margin-top: 20px; }
.intake-choice { min-width: 0; padding: 0; border: 0; }
.intake-choice legend { padding: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.intake-segment, .intake-chips { display: flex; gap: 8px; margin-top: 9px; }
.intake-option, .intake-chip { border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; }
.intake-option { flex: 1 1 0; border-radius: 12px; padding: 12px 6px; font-size: 14px; }
.intake-chip { border-radius: var(--r-pill); padding: 10px 15px; font-size: 13.5px; }
.intake-chips { flex-wrap: wrap; }
.intake-option.sel, .intake-chip.sel { border-color: var(--mint-500); background: var(--mint-50); color: var(--mint-700); font-weight: 600; }
.intake-option:hover, .intake-chip:hover { border-color: var(--mint-400); }
.intake-option:focus-visible, .intake-chip:focus-visible { outline: 2px solid var(--mint-400); outline-offset: 2px; }
.intake-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
#intake-save { width: 100%; margin-top: 24px; border-radius: 16px; padding: 16px; }

/* Короткие модалки из профиля: показывают только изменяемую настройку. */
.profile-modal { width: min(460px, 92vw); }
.profile-modal-body { gap: 0; padding-top: 8px; }
.profile-modal-save { width: 100%; margin-top: 24px; border-radius: 16px; padding: 15px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; padding: 14px; border-radius: 16px; }
#privacy-delete-submit { width: 100%; margin-top: 24px; border-radius: 16px; padding: 15px; }
.privacy-first-label { margin-top: 6px; }

/* ---------- Кризисные ресурсы ---------- */
.crisis-body { max-width: 620px; width: 100%; margin: 0 auto; padding: 20px 24px 32px; overflow-y: auto; }
.crisis-lead h1 { margin: 0; font-family: var(--font-serif); font-size: 23px; font-weight: 500; line-height: 1.28; }
.crisis-lead p { margin: 10px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.crisis-list { display: flex; flex-direction: column; gap: 10px; }
.crisis-call { display: flex; align-items: center; gap: 14px; padding: 15px 16px; color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.crisis-call:hover { border-color: var(--mint-300); }
.crisis-call-icon { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; color: var(--mint-600); background: var(--mint-50); border-radius: 13px; }
.crisis-call-icon .nav-ic { width: 22px; height: 22px; }
.crisis-call-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.crisis-call-copy b { font-size: 15px; font-weight: 600; }
.crisis-call-copy strong { margin-top: 2px; font-size: 16px; letter-spacing: .1px; }
.crisis-call-copy small { margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.crisis-call-go { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; color: #fff; background: var(--grad-accent); border-radius: 50%; box-shadow: 0 3px 10px rgba(76,180,151,.4); }
.crisis-call-go .nav-ic { width: 18px; height: 18px; }

/* ---------- Адаптив: сайдбар → нижний таб-бар ---------- */
@media (max-width: 860px) {
  .app-shell { display: block; }
  .main-area { height: calc(100vh - 74px); flex-direction: column; }
  /* Нижний таб-бар (фиксирован снизу) */
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: 74px;
    flex-direction: row; justify-content: space-around; align-items: stretch; gap: 0;
    padding: 10px 6px 0; border-right: 0; border-top: 1px solid var(--line);
    background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  }
  .brand, .brand-sub { display: none; }
  .nav-items { display: contents; }
  .sidebar-foot { display: block; flex: 1 1 0; min-width: 0; margin: 0; padding: 0; border: 0; position: static; }
  .nav-item {
    flex-direction: column; gap: 4px; flex: 1 1 0; min-width: 0; text-align: center;
    padding: 4px 0 0; border-radius: 0; font-size: 10.5px; color: var(--muted);
  }
  .nav-item span { flex: 0 0 auto; }
  .nav-item .nav-ic { width: 23px; height: 23px; }
  .nav-item:hover:not(:disabled), .nav-item.active { background: transparent; }
  .nav-item.active { color: var(--ink); }
  .nav-item.nav-plain span { white-space: normal; line-height: 1.1; }
  .sidebar-foot > .nav-item { width: 100%; height: 100%; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 4px 0 0; border-radius: 0; font-size: 10.5px; text-align: center; }
  .acct-btn { width: 100%; height: 100%; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 4px 0 0; border-radius: 0; }
  .acct-btn:hover { background: transparent; }
  .acct-av { width: 23px; height: 23px; font-size: 12px; }
  .acct-name { flex: 0 0 auto; max-width: 100%; text-align: center; font-size: 10.5px; line-height: 1.1; }
  .acct-btn .chev { display: none; }
  .acct-menu { position: fixed; right: 12px; bottom: 82px; left: 12px; }
  .msg { max-width: 88%; }
}
