/* Единая система ролей: экран выбора, плашка в шапке и выпадающий список. */

:root {
  --role-accent: #0b72a2;
  --role-teal: #18a6a8;
  --role-glow: rgba(11, 114, 162, .14);
  --role-card: rgba(255, 255, 255, .58);
  --role-menu: rgba(255, 255, 255, .76);
  --role-menu-line: rgba(255, 255, 255, .94);
  --role-check-bg: rgba(11, 114, 162, .90);
  --role-check-ink: #fff;
}

[data-theme=dark] {
  --role-accent: #7db8ea;
  --role-teal: #63d3c8;
  --role-glow: rgba(125, 184, 234, .20);
  --role-card: rgba(255, 255, 255, .09);
  --role-menu: rgba(28, 32, 40, .78);
  --role-menu-line: rgba(255, 255, 255, .24);
  --role-check-bg: rgba(125, 184, 234, .30);
  --role-check-ink: #f3f6fa;
}

/* ---- экран «Выберите роль» ---- */
.role-picker { padding-bottom: 24px; }

.role-intro { margin-bottom: 18px; }
.role-intro h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}
.role-subtitle {
  margin: 0;
  max-width: 360px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}
.role-user {
  margin: 10px 0 0;
  color: var(--mut);
  font-size: 13px;
  font-weight: 600;
}

.role-cards { display: flex; flex-direction: column; gap: 12px; }

.role-card {
  width: 100%;
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-panel);
  background-color: var(--role-card);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--glass-shadow);
  color: var(--ink);
  text-align: left;
  -webkit-backdrop-filter: blur(var(--blur-card)) saturate(var(--sat));
  backdrop-filter: blur(var(--blur-card)) saturate(var(--sat));
  transition: transform 120ms var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.role-card.on {
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 0 0 2px var(--role-glow), var(--glass-shadow);
}
.role-card:active { transform: scale(.99); }

.role-card-icon {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--role-accent), var(--role-teal));
  box-shadow: 0 8px 20px rgba(11, 114, 162, .24);
  color: #fff;
}
.role-card-icon svg { width: 23px; height: 23px; }

.role-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.role-card-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.role-card-desc { color: var(--mut); font-size: 12px; line-height: 1.35; }

.role-check {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: transparent;
}
.role-card.on .role-check {
  border-color: transparent;
  background: var(--role-check-bg);
  color: var(--role-check-ink);
}
.role-check svg { width: 16px; height: 16px; }

/* ---- плашка активной роли в шапке ---- */
.role-slot { flex: none; display: flex; align-items: center; }

.role-chip {
  min-height: 34px;
  max-width: 132px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  background-color: var(--glass-strong);
  box-shadow: inset 0 1px 0 var(--glass-shine);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  transition: background-color var(--dur) var(--ease), transform 120ms var(--ease);
}
.role-chip > svg:first-child { width: 16px; height: 16px; color: var(--accent); }
.role-chip .chev { width: 12px; height: 12px; color: var(--mut); }
.role-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-chip:active { transform: scale(.98); background-color: var(--glass); }

/* ---- выпадающий список ролей ---- */
.role-scrim {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: var(--menu-scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: roleFade 160ms var(--ease) both;
}
.role-panel {
  position: fixed;
  top: calc(68px + env(safe-area-inset-top) + 6px);
  left: 50%;
  z-index: 29;
  width: calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-width: 402px;
  padding: 8px;
  border: 1px solid var(--role-menu-line);
  border-radius: 18px;
  background-color: var(--role-menu);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--dialog-shadow);
  -webkit-backdrop-filter: blur(24px) saturate(var(--sat));
  backdrop-filter: blur(24px) saturate(var(--sat));
  transform: translateX(-50%);
  transform-origin: top center;
  animation: rolePop 180ms var(--ease) both;
}
.role-menu-title {
  margin: 4px 10px 6px;
  color: var(--mut);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.role-option {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.role-option.on { background: var(--role-glow); color: var(--accent); }
.role-option:active { background: var(--glass-strong); }
.role-option-icon {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.role-option-icon svg { width: 20px; height: 20px; }
.role-option-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-option-check {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--accent);
  opacity: 0;
}
.role-option.on .role-option-check { opacity: 1; }
.role-option-check svg { width: 18px; height: 18px; }

@keyframes roleFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rolePop {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.97); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@media (max-width: 360px) {
  .role-chip { max-width: 104px; padding: 5px 7px; gap: 5px; }
  .role-chip span { font-size: 11px; }
  .role-card { gap: 10px; padding: 12px; }
  .role-card-icon { width: 42px; height: 42px; }
}

@media (pointer: fine) {
  .role-card:hover { transform: translateY(-1px); }
  .role-option:hover { background: var(--glass-strong); }
}
