/* Buttons, the sign-in and registration cards, password field, user menu. */
/* Buttons (as on the sign-in card): primary = blue gradient with a soft glow,
   the rest = outlined in the accent colour. */
.btn {
  border: 1.5px solid color-mix(in srgb, var(--accent, #1c58d9) 35%, transparent);
  background: #fff;
  color: var(--accent, #1c58d9);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .1s;
}
.btn:hover:not(:disabled),
.btn:focus-visible {
  background: color-mix(in srgb, var(--accent, #1c58d9) 7%, #fff);
  border-color: var(--accent, #1c58d9);
  outline: none;
}
.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #1c58d9) 78%, #6a8dff), var(--accent, #1c58d9));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent, #1c58d9) 35%, transparent);
}
.btn.primary:hover:not(:disabled),
.btn.primary:focus-visible {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #1c58d9) 78%, #6a8dff), var(--accent, #1c58d9));
  border-color: transparent;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent, #1c58d9) 45%, transparent);
  transform: translateY(-1px);
}
.btn.primary:active:not(:disabled) { transform: translateY(0); }
/* Primary that is not ready yet (empty form, nothing to save): pale, no glow. */
.btn.primary:disabled,
.btn.primary.is-idle {
  color: color-mix(in srgb, var(--accent, #1c58d9) 70%, #fff);
  background: color-mix(in srgb, var(--accent, #1c58d9) 10%, #fff);
  box-shadow: none;
  transform: none;
  opacity: 1;
}
.btn.ghost { background: #fff; }
.btn.danger { color: #d24b4e; border-color: #f0c8c8; background: #fff; }
.btn.danger:hover:not(:disabled),
.btn.danger:focus-visible { background: #fdeeee; border-color: #d24b4e; }
.btn.wide { width: 100%; margin-top: 12px; padding: 12px 20px; border-radius: 12px; font-size: 15px; }
.btn:disabled, .send:disabled { opacity: .65; cursor: default; }
/* Sign-in card: «Войти» stays pale until both fields are filled. */
#login #form-login .login-submit.btn { margin-top: 16px; }
#login #form-login .login-submit.btn:not(.is-ready) {
  color: color-mix(in srgb, var(--accent, #1c58d9) 70%, #fff);
  background: color-mix(in srgb, var(--accent, #1c58d9) 10%, #fff);
  box-shadow: none;
  transform: none;
}
.auth-alt-btn {
  display: block;
  margin-top: 10px;
  padding: 10px 20px;
  border: 1.5px solid color-mix(in srgb, var(--accent, #1c58d9) 35%, transparent);
  border-radius: 12px;
  background: #fff;
  color: var(--accent, #1c58d9);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background .2s, border-color .2s;
}
.auth-alt-btn:hover,
.auth-alt-btn:focus-visible {
  background: color-mix(in srgb, var(--accent, #1c58d9) 7%, transparent);
  border-color: var(--accent, #1c58d9);
  outline: none;
}
#form-login .form-error { min-height: 0; margin-top: 6px; }
#login-fields {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
}
.password-wrap { position: relative; width: 100%; }
.password-wrap input { padding-right: 40px; }
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: #8b8e98;
  cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible { color: var(--accent, #1c58d9); outline: none; }
/* Hidden (default): slashed eye. Revealed: open eye. */
.password-toggle .eye-open { display: none; }
.password-toggle .eye-closed { display: block; }
.password-toggle[aria-pressed="true"] .eye-open { display: block; }
.password-toggle[aria-pressed="true"] .eye-closed { display: none; }
#form-login .auth-switch { margin: 6px 0 0; }
#form-login .auth-setup-toggle { margin-top: 12px; }
/* Register submit and the waiting-screen login: pale until ready. */
#register-submit.btn.primary:not(.is-ready),
#register-waiting-login.btn.primary:not(.is-ready) {
  color: color-mix(in srgb, var(--accent, #1c58d9) 70%, #fff);
  background: color-mix(in srgb, var(--accent, #1c58d9) 10%, #fff);
  box-shadow: none;
  transform: none;
}
#register-waiting-login.btn.primary:not(.is-ready) { cursor: default; }

.app {
  position: relative;
  z-index: 1;
  height: 100%; display: flex; min-height: 0; width: 100%; max-width: 100%; overflow: hidden;
}
.team-rail {
  width: 68px; background: var(--rail); display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; min-height: 0; position: relative; z-index: 4; gap: 10px;
}
.team-rail .team-mark.rail-home {
  appearance: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  background: transparent; flex: none;
}
.team-rail .team-mark.rail-home:focus-visible {
  outline: 2px solid rgba(255,255,255,.75); outline-offset: 2px;
}
.rail-tools {
  display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none;
}
.team-rail .rail-me-bar {
  margin-top: auto;
  margin-bottom: 4px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.team-rail .rail-me-bar .me-button {
  width: 44px;
  height: 44px;
}
.team-rail .rail-me-bar .me-button .avatar {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px;
  max-width: 36px; max-height: 36px; flex: 0 0 36px; font-size: 13px;
}
/* Menu opens to the right of the bottom-left avatar. */
.team-rail .rail-me-bar .user-menu {
  left: calc(100% + 10px);
  right: auto;
  bottom: 0;
  top: auto;
  max-height: min(70vh, 520px);
}
.rail-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.72);
  -webkit-tap-highlight-color: transparent;
}
.rail-btn svg { display: block; }
.rail-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.rail-btn:focus-visible { outline: 2px solid rgba(255,255,255,.75); outline-offset: 2px; }
.rail-btn.is-active {
  color: #fff; background: rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.app.rail-feature-open .thread,
.app.rail-feature-open .composer-wrap,
.app.rail-feature-open .channel-header { display: none !important; }
/* Tasks reuses the glass channel header (#/name · Задачи + search),
   with the same inset under the header as the dialogue overlay. */
.app.rail-feature-open.feature-chrome-open .channel-header {
  display: flex !important;
  padding-left: 12px;
}
.app.rail-feature-open.feature-chrome-open #feature-screen {
  padding-top: calc(var(--chat-scroll-top, 76px) + 12px);
  padding-left: 12px;
  padding-right: 12px;
}
/* Mail list: bottom composer stays hidden. It appears only while a letter window is open. */
.app.rail-feature-open.mail-mode:not(.mail-dialog-open) .composer-wrap {
  display: none !important;
}
.app.rail-feature-open.mail-mode.mail-dialog-open .composer-wrap {
  display: block !important;
  z-index: 8;
}
.app.rail-feature-open.mail-mode.feature-chrome-open #feature-screen {
  top: 0;
  left: 18px !important;
  right: 18px !important;
  width: auto !important;
  bottom: 8px;
  height: auto;
  padding-top: calc(var(--chat-scroll-top, 76px) + 12px);
  padding-bottom: 4px;
  padding-left: 0 !important;
  padding-right: 0 !important;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
  box-sizing: border-box;
}
.app.rail-feature-open #feature-screen { display: flex; }
.app.dialogue-open #feature-screen,
.app.notif-center-open #feature-screen { display: none !important; }

/* Registration by email: the 8-digit code from the letter */
#reg-code.code-cells { display: flex; justify-content: center; gap: 6px; margin: 14px 0 6px; }
#reg-code .code-cell {
  width: 38px !important; min-width: 0; margin: 0; flex: 0 0 38px; height: 50px; padding: 0; box-sizing: border-box; flex: none;
  border: 1.5px solid #d8dce4; border-radius: 12px; background: #f6f7fa;
  text-align: center; font: inherit; font-size: 22px; font-weight: 700; color: #1a1d26;
  font-variant-numeric: tabular-nums; caret-color: var(--accent, #1c58d9);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
#reg-code .code-cell:focus { outline: none; background: #fff; border-color: var(--accent, #1c58d9); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #1c58d9) 18%, transparent); }
#reg-code .code-cell.is-split { margin-right: 10px; }
#reg-code .code-cell:disabled { opacity: .6; }
.register-code-lead { text-align: center; }
.register-code-change { display: block; margin-top: 12px; text-align: center; font-size: 14px; color: var(--accent); font-weight: 700; text-decoration: none; }
.register-code-change:hover { text-decoration: underline; }
#register-code-resend { margin-top: 10px; }
.register-email-ok { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: #e7f6ee; color: #0f7a4d; font-size: 14px; overflow-wrap: anywhere; }
@media (max-width: 380px) {
  #reg-code.code-cells { gap: 4px; }
  #reg-code .code-cell { width: 31px !important; flex-basis: 31px; height: 46px; font-size: 20px; }
  #reg-code .code-cell.is-split { margin-right: 6px; }
}
.register-email-lead { text-align: center; margin: 4px 0 6px; }

/* Sign-in through Яндекс ID */
.ext-auth { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ext-auth.hidden, .ext-auth.is-off { display: none !important; }
.ext-auth-or { display: flex; align-items: center; gap: 10px; color: #8b8e98; font-size: 13px; }
.ext-auth-or::before, .ext-auth-or::after { content: ""; flex: 1; border-top: 1px solid #e4e7ec; }
.ext-auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 44px;
  border: 1px solid #d8dce4; border-radius: 10px; background: #fff; color: #1a1d26;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.ext-auth-btn[hidden] { display: none; }
.ext-auth-btn:hover { background: #f6f7fa; border-color: #c5cad3; }
.ext-auth-btn svg { flex: none; }
/* Profile → «Способы входа» */
.sign-in-ways { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.sign-in-ways.hidden { display: none; }
.sign-in-way { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #e8eaef; border-radius: 10px; }
.sign-in-way strong { font-size: 15px; }
.sign-in-way-state { font-size: 13px; color: #8b8e98; }
.sign-in-way-state.is-on { color: #0f7a4d; }
.sign-in-way .btn { padding: 6px 12px; }
.sign-in-way-note { margin: 2px 0 0; }

/* «Инвайт-код в Telegram»: the form's Telegram field and the code step */
.register-telegram-why { margin: -4px 0 12px; color: #6b7080; font-size: 13px; line-height: 1.4; }
#register-invite .lede { text-align: center; margin: 4px 0 12px; }
.tg-open { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; text-decoration: none; }
.tg-open.hidden { display: none; }
.tg-open svg { flex: none; }
#reg-invite-code { text-align: center; letter-spacing: .18em; text-transform: uppercase; font-weight: 600; }
#reg-invite-code::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }

/* «Восстановить пароль» */
.login-forgot { display: block; margin: -2px 0 10px; text-align: center; font-size: 14px; font-weight: 600; color: var(--accent, #1c58d9); text-decoration: none; }
.login-forgot.hidden { display: none; }
.login-forgot:hover { text-decoration: underline; }
#form-reset .lede { text-align: center; }
.reset-ways { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
#reset-code { text-align: center; letter-spacing: .2em; font-weight: 600; font-size: 20px; }
#reset-code::placeholder { letter-spacing: .2em; font-weight: 400; }
#reset-resend { margin-top: 10px; }

#form-tglogin .lede { text-align: center; }
#tgl-code { text-align: center; letter-spacing: .2em; font-weight: 600; font-size: 20px; }
#tgl-code::placeholder { letter-spacing: .2em; font-weight: 400; }
#tgl-resend { margin-top: 10px; }

/* Sign-in screen: Telegram and Яндекс ID as two shortcuts in a row */
.ext-auth-row { display: flex; justify-content: center; gap: 12px; }
.ext-auth-btn.ext-auth-icon { flex: 1 1 0; max-width: 170px; height: 52px; gap: 8px; font-size: 14px; }
.ext-auth-btn.ext-auth-icon[hidden] { display: none; }

/* Under «Пароль» / «Подтверждение»: the password policy, live */
.pw-rules { list-style: none; margin: 4px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pw-rules:empty { display: none; }
/* «Пароль»: the requirements float under the field while it has the focus */
.pw-rules.is-popover { display: none; position: fixed; z-index: 1200; left: var(--pw-left, 0); top: var(--pw-top, 0); width: var(--pw-width, 260px);
  max-width: calc(100vw - 16px); box-sizing: border-box; margin: 0; padding: 10px 12px; gap: 4px;
  background: #fff; border: 1px solid #e3e6ee; border-radius: 12px; box-shadow: 0 10px 28px rgba(16, 24, 40, .16); }
.pw-rules.is-popover.is-open { display: flex; }
.pw-rules.is-popover::before { content: ""; position: absolute; top: -6px; left: 22px; width: 10px; height: 10px; background: #fff;
  border-left: 1px solid #e3e6ee; border-top: 1px solid #e3e6ee; transform: rotate(45deg); }
.pw-rule { display: flex; align-items: center; gap: 7px; font-size: calc(12.5px * var(--text-scale, 1)); line-height: 1.35; color: #6b7080; }
.pw-rule-mark { width: 16px; height: 16px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; background: #c9cdd6; }
.pw-rule.is-ok { color: #1e7a45; }
.pw-rule.is-ok .pw-rule-mark { background: #22a35a; }
.pw-rule.is-bad { color: #c2383b; }
.pw-rule.is-bad .pw-rule-mark { background: #d24b4e; }
/* «Подтверждение»: ✓ / ✕ at the end of the field */
.pw-confirm-wrap { position: relative; width: 100%; }
.pw-match-mark { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%;
  display: none; place-items: center; font-size: 12px; font-weight: 800; color: #fff; pointer-events: none; }
.pw-match-mark.has-eye { right: 42px; }
.pw-match-mark.is-ok { display: grid; background: #22a35a; }
.pw-match-mark.is-bad { display: grid; background: #d24b4e; }
input.has-pw-mark { padding-right: 38px; }
.password-wrap input.has-pw-mark { padding-right: 70px; }
/* Wizard → «Настройка базы данных»: «Использовать шифрование» switch. */
.auth-card .setup-db-remote {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
}
.auth-card .setup-db-remote.hidden { display: none; }
.auth-card label.setup-crypto-toggle {
  display: flex; align-items: center; gap: 14px; margin: 14px 0 4px; padding: 12px 14px;
  border: 1px solid #e3e5eb; border-radius: 12px; background: #f8f9fb; cursor: pointer;
  font-weight: inherit; text-align: left;
}
.auth-card label.setup-crypto-toggle.hidden { display: none; }
.setup-crypto-toggle .settings-toggle-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.setup-crypto-toggle .settings-toggle-text strong { font-size: 15px; color: #1a1d26; }
.setup-crypto-toggle .settings-toggle-text span { font-size: 13px; font-weight: 400; line-height: 1.35; color: #6b7080; }
.setup-crypto-toggle input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.setup-crypto-toggle .settings-toggle-ui {
  flex: none; position: relative; display: block; width: 44px; height: 26px;
  border-radius: 999px; background: #d0d4dc; transition: background .15s ease;
}
.setup-crypto-toggle .settings-toggle-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(20, 28, 45, .2);
  transition: transform .15s ease;
}
.setup-crypto-toggle input:checked + .settings-toggle-ui { background: var(--accent, #2f6fd6); }
.setup-crypto-toggle input:checked + .settings-toggle-ui::after { transform: translateX(18px); }
.setup-crypto-toggle input:focus-visible + .settings-toggle-ui { outline: 2px solid var(--accent, #2f6fd6); outline-offset: 2px; }
