/**
 * GNZDEV IRC Chat Client - Estilo Apple Human Interface
 */

.irc-view-container {
  display: flex;
  height: 100%;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas);
}

/* Columna Izquierda: Canales IRC */
.irc-channels-sidebar {
  width: 220px;
  min-width: 220px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.irc-sidebar-header {
  padding: 1rem 1.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Desplegable para ingresar / unirse a canales */
.irc-channel-dropdown-wrap {
  padding: 0.6rem 0.65rem 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.irc-channel-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--apple-cyan);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  appearance: auto;
}

.irc-channel-select:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(0, 199, 190, 0.5);
}

.irc-channel-select:focus {
  border-color: var(--apple-cyan);
  box-shadow: 0 0 0 2px rgba(0, 199, 190, 0.25);
}

.irc-channel-select option {
  background: #18181C;
  color: #fff;
  padding: 6px;
}

/* Botón cerrar / salir de canal activo */
.channel-part-btn {
  display: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: all 0.12s ease;
}

.irc-channel-btn:hover .channel-part-btn {
  display: inline-block;
}

.channel-part-btn:hover {
  color: #FF453A;
  background: rgba(255, 69, 58, 0.2);
}

.irc-channels-list {
  list-style: none;
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
}

.irc-channel-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.irc-channel-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.irc-channel-btn.active {
  background: rgba(0, 122, 255, 0.15);
  color: var(--apple-blue);
}

.channel-tag-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.channel-unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--apple-orange);
  display: none;
}

.channel-unread-dot.visible {
  display: block;
}

/* Subencabezado y Lista de Chats Privados */
.irc-sidebar-subheader {
  padding: 0.65rem 0.85rem 0.35rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 0.35rem;
}

.irc-dm-total-badge {
  background: var(--apple-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.2;
}

.irc-direct-list {
  list-style: none;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  max-height: 260px;
}

.irc-dm-item {
  width: 100%;
}

.irc-dm-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

.irc-dm-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.irc-dm-btn.active {
  background: rgba(0, 122, 255, 0.16);
  color: var(--apple-blue);
}

.irc-dm-avatar-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.irc-dm-avatar-thumb {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  background: #18181a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: block;
}

.irc-dm-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--apple-green);
  border: 1.5px solid var(--bg-sidebar);
}

.irc-dm-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.irc-dm-name {
  font-weight: 700;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.irc-dm-preview {
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.irc-dm-unread-badge {
  background: var(--apple-blue);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.irc-dm-close-btn {
  font-size: 0.72rem;
  opacity: 0.3;
  padding: 2px 4px;
  border-radius: 4px;
  margin-left: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.irc-dm-btn:hover .irc-dm-close-btn {
  opacity: 0.8;
}

.irc-dm-close-btn:hover {
  opacity: 1;
  color: var(--apple-red);
  background: rgba(255, 69, 58, 0.15);
}

.irc-dm-empty {
  padding: 0.6rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.35;
}

.irc-dm-empty code {
  color: var(--apple-cyan);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 3px;
  border-radius: 3px;
}

/* Área Central de Mensajes */
.irc-chat-main {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  position: relative;
}

.irc-chat-topbar {
  height: 52px;
  min-height: 52px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.irc-current-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.irc-current-channel {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.irc-channel-topic {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 480px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.irc-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.irc-icon-btn {
  background: var(--btn-secondary-bg, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.irc-icon-btn:hover {
  background: var(--btn-secondary-hover, rgba(255, 255, 255, 0.12));
  color: var(--text-primary);
}

.irc-icon-btn.active {
  background: var(--apple-blue);
  color: #FFFFFF;
  border-color: var(--apple-blue);
}

.irc-icon-btn.active-oper {
  background: rgba(255, 149, 0, 0.16) !important;
  color: #FF9500 !important;
  border-color: rgba(255, 149, 0, 0.6) !important;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(255, 149, 0, 0.25);
}

/* Flujo de Mensajes IRC */
.irc-messages-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-family: var(--font-apple);
  font-size: 0.92rem;
}

.irc-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.45;
  word-break: break-word;
}

.irc-msg-row.irc-msg-mine {
  background: rgba(0, 122, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: 0 -6px;
}

.irc-msg-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

.irc-msg-nick {
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
  cursor: pointer;
}

.irc-msg-text {
  color: var(--text-primary);
  flex: 1;
}

.irc-msg-text a {
  color: var(--apple-cyan);
  text-decoration: underline;
}

/* Mensajes de Sistema / Servidor */
.irc-msg-system {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.irc-msg-system .sys-bullet {
  color: var(--apple-blue);
}

.irc-msg-action {
  color: var(--apple-purple);
  font-style: italic;
  font-weight: 500;
}

/* Barra de Entrada de Chat */
.irc-chat-input-bar {
  position: relative;
  flex-shrink: 0;
  z-index: 10;
  padding: 0.75rem 1.25rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  box-sizing: border-box;
}

.irc-nick-badge-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--apple-blue);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.irc-nick-badge-btn:hover {
  background: rgba(0, 122, 255, 0.15);
}

.irc-input-field {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.95rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.irc-input-field:focus {
  outline: none;
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.irc-input-action-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  color: var(--text-primary);
  line-height: 1;
  padding: 0;
}

.irc-input-action-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.irc-input-action-btn.active {
  background: rgba(0, 122, 255, 0.25);
  border-color: var(--apple-blue);
}

/* Popovers de Chat: Emojis y Estilos */
.irc-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 1.25rem;
  background: var(--bg-popover);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
  flex-direction: column;
  animation: ircPopoverIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.irc-popover.open {
  display: flex;
}

@keyframes ircPopoverIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.irc-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.5rem;
}

.irc-popover-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.irc-popover-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.irc-popover-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Emoji Popover */
.irc-emoji-popover {
  width: 320px;
  max-width: 90vw;
  height: 290px;
}

.irc-emoji-tabs {
  display: flex;
  gap: 4px;
}

.irc-emoji-tab-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.irc-emoji-tab-btn:hover,
.irc-emoji-tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
}

.irc-emoji-grid {
  flex: 1;
  padding: 0.5rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.irc-emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.12s ease;
}

.irc-emoji-item:hover {
  transform: scale(1.3);
  background: rgba(255, 255, 255, 0.14);
}

/* Style & Colors Popover */
.irc-style-popover {
  width: 310px;
  max-width: 90vw;
}

.irc-style-body {
  padding: 0.85rem;
}

.irc-style-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.irc-format-btn-group {
  display: flex;
  gap: 6px;
  margin-bottom: 0.65rem;
}

.irc-format-btn {
  flex: 1;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0.45rem 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.irc-format-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--border-medium);
}

.irc-format-btn-reset {
  flex: 1.5;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.irc-format-btn-reset:hover {
  color: #FF453A;
  background: rgba(255, 69, 58, 0.15);
  border-color: rgba(255, 69, 58, 0.35);
}

.irc-color-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 4px 0;
}

.irc-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  padding: 0;
}

.irc-color-swatch:hover {
  transform: scale(1.28);
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.irc-style-hint {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.55rem;
}

/* Columna Derecha: Lista de Usuarios en Canal */
.irc-users-sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.irc-users-header {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.irc-users-list {
  list-style: none;
  padding: 0.6rem 0.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.irc-user-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  user-select: none;
  cursor: pointer;
}

.irc-user-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.irc-user-item.active-dm {
  background: rgba(0, 122, 255, 0.16);
  color: var(--apple-blue);
}

.user-dm-action-icon {
  font-size: 0.76rem;
  opacity: 0;
  color: var(--apple-blue);
  margin-left: auto;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.irc-user-item:hover .user-dm-action-icon {
  opacity: 0.9;
}

.user-avatar-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-avatar-thumb {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: #18181a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: block;
}

.user-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--apple-green);
  border: 2px solid var(--bg-sidebar);
  flex-shrink: 0;
}

.user-name-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-nick-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.user-role-prefix {
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  flex-shrink: 0;
}
.user-role-prefix.op {
  color: var(--apple-orange);
}
.user-role-prefix.voice {
  color: var(--apple-cyan);
}

/* Botones móviles para alternar paneles de canales y usuarios */
.irc-mobile-nav-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  line-height: 1;
}
.irc-mobile-nav-btn:hover,
.irc-mobile-nav-btn:active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Telón de fondo oscuro para paneles móviles */
.irc-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.irc-mobile-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-close-drawer-btn {
  display: none;
  background: var(--btn-secondary-bg, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.mobile-close-drawer-btn:hover {
  background: var(--btn-secondary-hover, rgba(255, 255, 255, 0.15));
  color: var(--text-primary);
}

@media (max-width: 1100px) {
  .irc-mobile-nav-btn.users-toggle {
    display: inline-flex;
  }

  .irc-users-sidebar {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    z-index: 190;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -12px 0 35px rgba(0, 0, 0, 0.7);
    display: flex !important;
    background: var(--bg-sidebar);
  }
  .irc-users-sidebar.mobile-open {
    transform: translateX(0);
  }
  .irc-users-sidebar .mobile-close-drawer-btn {
    display: inline-flex;
  }
}

.apple-app-layout .irc-channels-sidebar,
.apple-app-layout .irc-users-sidebar {
  top: 60px;
}

@media (max-width: 768px) {
  .irc-mobile-nav-btn {
    display: inline-flex;
  }

  .irc-channels-sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 270px;
    max-width: 82vw;
    z-index: 190;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.7);
    background: var(--bg-sidebar);
  }
  .irc-channels-sidebar.mobile-open {
    transform: translateX(0);
  }
  .irc-channels-sidebar .mobile-close-drawer-btn {
    display: inline-flex;
  }

  .irc-chat-topbar {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
  .irc-channel-topic {
    display: none;
  }
  .irc-topbar-actions .irc-icon-btn span {
    display: none;
  }

  .irc-chat-main {
    height: 100%;
    min-height: 0;
    min-width: 0;
  }
  .irc-messages-scroll {
    min-height: 0;
  }

  .irc-chat-input-bar {
    padding: 0.5rem 0.65rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
    gap: 5px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .irc-input-field {
    padding: 0.55rem 0.75rem;
    font-size: 16px; /* Evita que Safari en iOS haga zoom al tocar el input */
    min-width: 0;
  }
  .irc-nick-badge-btn {
    padding: 0.45rem 0.55rem;
    font-size: 0.78rem;
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .irc-input-action-btn {
    width: 34px;
    height: 34px;
    font-size: 1rem;
    flex-shrink: 0;
  }
  .irc-chat-input-bar .btn-apple.btn-primary {
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .irc-chat-input-bar {
    padding: 0.35rem 0.45rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0.45rem));
    gap: 4px;
    flex-shrink: 0;
  }
  .irc-nick-badge-btn {
    padding: 0.45rem 0.35rem;
    max-width: 32px;
    min-width: 32px;
    text-align: center;
    flex-shrink: 0;
    box-sizing: border-box;
  }
  .irc-nick-badge-btn span.nick-text {
    display: none;
  }
  .irc-input-field {
    font-size: 16px; /* Evita que Safari en iOS haga zoom al tocar el input */
    min-width: 0;
    padding: 0.45rem 0.6rem;
  }
  .irc-input-action-btn {
    width: 30px;
    min-width: 30px;
    height: 32px;
    font-size: 0.95rem;
    padding: 0;
    flex-shrink: 0;
  }
  .irc-chat-input-bar .btn-apple.btn-primary {
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
    flex-shrink: 0;
  }
  .irc-messages-scroll {
    padding: 0.75rem 0.65rem;
    gap: 0.35rem;
    font-size: 0.86rem;
    min-height: 0;
  }
  .irc-popover {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
  }
  .irc-msg-image-wrap {
    max-width: 100%;
  }
}

/* Subida y visualización de imágenes en chats privados (Retención 15 días) */
.irc-msg-image-wrap {
  margin: 6px 0;
  max-width: 380px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: inline-block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.irc-msg-image-wrap:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.25);
}
.irc-msg-image-link {
  display: block;
  cursor: zoom-in;
  line-height: 0;
  background: #0d0d0f;
}
.irc-msg-image {
  max-width: 100%;
  max-height: 320px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 10px 10px 0 0;
}
.irc-msg-image-meta {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.irc-msg-image-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--apple-cyan);
  font-weight: 600;
}
.irc-msg-image-expired {
  padding: 8px 12px;
  background: rgba(255, 69, 58, 0.1);
  border: 1px dashed rgba(255, 69, 58, 0.3);
  border-radius: 8px;
  color: var(--apple-red);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Modal lightbox de previsualización de imagen */
.irc-image-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  cursor: zoom-out;
}
.irc-image-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  cursor: default;
}
.irc-image-modal-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.irc-image-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2c2c2e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.irc-image-modal-close:hover {
  background: var(--apple-red);
  transform: scale(1.1);
}

/* Utilidad de accesibilidad: visible sólo para lectores de pantalla */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Validación de apodo invitado */
.form-error {
  margin-top: 6px;
  color: var(--apple-red);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}

.form-input.is-invalid {
  border-color: var(--apple-red);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.16);
}

.form-hint--compact {
  margin-top: 4px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.irc-register-privacy-note {
  margin: 0.9rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* Estado vacío de canal: no es un mensaje del chat */
.irc-channel-empty {
  margin: auto;
  width: min(100%, 540px);
  padding: 1.5rem 1.35rem;
  text-align: center;
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-lg, 14px);
  background: rgba(0, 122, 255, 0.045);
  color: var(--text-secondary);
}

.irc-channel-empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(0, 122, 255, 0.14);
  color: var(--apple-cyan);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
}

.irc-channel-empty-title {
  margin: 0 0 0.55rem;
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.irc-channel-empty-topic {
  margin: 0 0 0.75rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.irc-channel-empty-label {
  color: var(--apple-cyan);
  font-weight: 700;
}

.irc-channel-empty-topic--missing {
  color: var(--text-muted);
  font-style: italic;
}

.irc-channel-empty-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.irc-channel-empty code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--apple-cyan);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.irc-users-empty,
.irc-channels-empty {
  padding: 0.65rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
  list-style: none;
}

/* Los emojis son botones: reset visual conservando la apariencia existente */
button.irc-emoji-item {
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  line-height: 1;
}

.irc-emoji-item:focus-visible,
.irc-emoji-tab-btn:focus-visible,
.irc-color-swatch:focus-visible,
.irc-format-btn:focus-visible,
.irc-popover-close:focus-visible,
.irc-input-action-btn:focus-visible,
.irc-nick-badge-btn:focus-visible {
  outline: 2px solid var(--apple-blue);
  outline-offset: 2px;
}

